diff --git a/app/models/tag.rb b/app/models/tag.rb index ebbf35987a..277b58d990 100644 --- a/app/models/tag.rb +++ b/app/models/tag.rb @@ -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) + + return unless saved_change_to_name? && name_before_last_save.present? + + # 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 before_destroy :clear_tag_nominations diff --git a/features/tag_sets/tag_set_nominations.feature b/features/tag_sets/tag_set_nominations.feature index d82f636159..aee7353548 100644 --- a/features/tag_sets/tag_set_nominations.feature +++ b/features/tag_sets/tag_set_nominations.feature @@ -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"