Skip to content

Commit

Permalink
AO3-5538 Update tag set nominations with old tagname when renaming ta…
Browse files Browse the repository at this point in the history
…gs (#4922)

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

* Attempt to annoy reviewdog

* AO3-5538 Rubocop

* AO3-5538 Unannoy reviewdog
  • Loading branch information
Bilka2 authored Oct 5, 2024
1 parent f607097 commit 709a95b
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)

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"

0 comments on commit 709a95b

Please sign in to comment.