Skip to content

Commit

Permalink
AO3-5538 Update tag set nominations with old tagname when renaming tags
Browse files Browse the repository at this point in the history
  • Loading branch information
Bilka2 committed Sep 19, 2024
1 parent 0d51725 commit 6eabfea
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
10 changes: 10 additions & 0 deletions app/models/tag.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1188,6 +1188,16 @@ def update_tag_nominations
parent_names << "" if parent_names.present?

TagNomination.where(tagname: name, parent_tagname: parent_names).update_all(parented: true)

if saved_change_to_name? && name_before_last_save.present?

Check warning on line 1192 in app/models/tag.rb

View workflow job for this annotation

GitHub Actions / Rubocop

[rubocop] reported by reviewdog 🐶 Use a guard clause (`return unless saved_change_to_name? && name_before_last_save.present?`) instead of wrapping the code inside a conditional expression. Raw Output: app/models/tag.rb:1192:5: C: Style/GuardClause: Use a guard clause (`return unless saved_change_to_name? && name_before_last_save.present?`) instead of wrapping the code inside a conditional expression.
# Act as if the tag with the previous name was deleted and mirror clear_tag_nominations
TagNomination.where(tagname: name_before_last_save).update_all(
canonical: false,
exists: false,
parented: false,
synonym: nil
)
end
end

before_destroy :clear_tag_nominations
Expand Down
16 changes: 16 additions & 0 deletions features/tag_sets/tag_set_nominations.feature
Original file line number Diff line number Diff line change
Expand Up @@ -322,3 +322,19 @@ Feature: Nominating and reviewing nominations for a tag set
And I should not see "Someone else has already nominated the tag for this set but in fandom First."
And I should not see "Gold"
And I should see "None nominated in this fandom."

Scenario: A nominated canonical tag can be renamed by a tag wrangling admin without affecting the nomination
Given a canonical character "Before" in fandom "Treasure Chest"
And I am logged in as "tagsetter"
And I set up the nominated tag set "Nominated Tags" with 1 fandom nom and 1 character nom
And I nominate fandom "Treasure Chest" and character "Before" in "Nominated Tags" as "tagsetter"
When I am logged in as an "tag_wrangling" admin
And I edit the tag "Before"
And I fill in "Name" with "After"
And I press "Save changes"
Then I should see "Tag was updated."
When I am logged in as "tagsetter"
And I go to the "Nominated Tags" tag set page
And I follow "My Nominations"
Then I should see "Treasure Chest"
And I should see "Before"

0 comments on commit 6eabfea

Please sign in to comment.