Add ability to mark tags as deprecated
* Deprecated tags can't be added to posts, but existing deprecated tags in a post won't be removed * Only empty tags can be marked as deprecated manually * No tags can be manually undeprecated ** These limits don't apply to admins * Deprecating or undeprecating a tag will create a new mod action to prevent people from going rogue * Added deprecate/undeprecate commands for BURs * Deprecating a tag via BUR removes all implications to and from it as well
This commit is contained in:
@@ -446,6 +446,34 @@ class BulkUpdateRequestTest < ActiveSupport::TestCase
|
||||
end
|
||||
end
|
||||
|
||||
context "the deprecate command" do
|
||||
should "deprecate the tag" do
|
||||
@tag = create(:tag, name: "silver_hair")
|
||||
@bur = create_bur!("deprecate silver_hair", @admin)
|
||||
|
||||
assert_equal(true, @tag.reload.is_deprecated?)
|
||||
end
|
||||
|
||||
should "remove implications" do
|
||||
@ti1 = create(:tag_implication, antecedent_name: "silver_hair", consequent_name: "old_woman")
|
||||
@ti2 = create(:tag_implication, antecedent_name: "my_literal_dog", consequent_name: "silver_hair")
|
||||
@bur = create_bur!("deprecate silver_hair", @admin)
|
||||
|
||||
assert_equal("deleted", @ti1.reload.status)
|
||||
assert_equal("deleted", @ti2.reload.status)
|
||||
assert_equal("approved", @bur.reload.status)
|
||||
end
|
||||
end
|
||||
|
||||
context "the undeprecate command" do
|
||||
should "undeprecate the tag" do
|
||||
@tag = create(:tag, name: "silver_hair", is_deprecated: true)
|
||||
@bur = create_bur!("undeprecate silver_hair", @admin)
|
||||
|
||||
assert_equal(false, @tag.reload.is_deprecated?)
|
||||
end
|
||||
end
|
||||
|
||||
context "that contains a mass update followed by an alias" do
|
||||
should "make the alias take effect after the mass update" do
|
||||
@p1 = create(:post, tag_string: "maid_dress")
|
||||
|
||||
@@ -479,6 +479,23 @@ class PostTest < ActiveSupport::TestCase
|
||||
end
|
||||
end
|
||||
|
||||
context "tagged with a deprecated tag" do
|
||||
should "not remove the tag if the tag was already in the post" do
|
||||
bad_tag = create(:tag, name: "bad_tag")
|
||||
old_post = FactoryBot.create(:post, tag_string: "bad_tag")
|
||||
bad_tag.update!(is_deprecated: true)
|
||||
old_post.update!(tag_string: "asd bad_tag")
|
||||
assert_equal("asd bad_tag", old_post.reload.tag_string)
|
||||
|
||||
end
|
||||
|
||||
should "not add the tag if it is being added" do
|
||||
create(:tag, name: "a_bad_tag", is_deprecated: true)
|
||||
@post.update!(tag_string: "asd a_bad_tag")
|
||||
assert_equal("asd", @post.reload.tag_string)
|
||||
end
|
||||
end
|
||||
|
||||
context "tagged with a metatag" do
|
||||
context "for typing a tag" do
|
||||
setup do
|
||||
|
||||
Reference in New Issue
Block a user