Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AO3-5538 Update tag set nominations with old tagname when renaming tags #4922

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)

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
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"
Loading