Merge pull request #5302 from nonamethanks/tag-deprecation-aliases

Tags: remove aliases when deprecating a tag
This commit is contained in:
evazion
2022-10-21 01:02:39 -05:00
committed by GitHub
2 changed files with 4 additions and 1 deletions

View File

@@ -217,6 +217,7 @@ class BulkUpdateRequestProcessor
when :deprecate
tag = Tag.find_or_create_by_name(args[0])
tag.update!(is_deprecated: true, updater: User.system)
TagAlias.active.where(consequent_name: tag.name).each { |ti| ti.reject!(User.system) }
TagImplication.active.where(consequent_name: tag.name).each { |ti| ti.reject!(User.system) }
TagImplication.active.where(antecedent_name: tag.name).each { |ti| ti.reject!(User.system) }

View File

@@ -611,14 +611,16 @@ class BulkUpdateRequestTest < ActiveSupport::TestCase
assert_equal(true, @tag.reload.is_deprecated?)
end
should "remove implications" do
should "remove implications and aliases" do
@ti1 = create(:tag_implication, antecedent_name: "grey_hair", consequent_name: "old_woman")
@ti2 = create(:tag_implication, antecedent_name: "my_literal_dog", consequent_name: "grey_hair")
@ta = create(:tag_alias, antecedent_name: "silver_hair", consequent_name: "grey_hair")
@wiki = create(:wiki_page, title: "grey_hair")
@bur = create_bur!("deprecate grey_hair", @admin)
assert_equal("deleted", @ti1.reload.status)
assert_equal("deleted", @ti2.reload.status)
assert_equal("deleted", @ta.reload.status)
assert_equal("approved", @bur.reload.status)
end