Merge pull request #5104 from nonamethanks/no-wiki-no-deprecation
Tags: don't allow deprecation of tags without wiki
This commit is contained in:
@@ -446,34 +446,6 @@ 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")
|
||||
@@ -578,6 +550,42 @@ class BulkUpdateRequestTest < ActiveSupport::TestCase
|
||||
end
|
||||
end
|
||||
|
||||
context "using the deprecate command" do
|
||||
should "deprecate the tag" do
|
||||
@tag = create(:tag, name: "bad_tag")
|
||||
create(:wiki_page, title: "bad_tag")
|
||||
@bur = create_bur!("deprecate bad_tag", @admin)
|
||||
|
||||
assert_equal(true, @tag.reload.is_deprecated?)
|
||||
end
|
||||
|
||||
should "remove implications" 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")
|
||||
@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("approved", @bur.reload.status)
|
||||
end
|
||||
|
||||
should "not work for tags without a wiki page" do
|
||||
@bur = build(:bulk_update_request, script: "deprecate no_wiki")
|
||||
assert_equal(false, @bur.valid?)
|
||||
assert_equal(["Can't deprecate no_wiki (tag must have a wiki page)"], @bur.errors[:base])
|
||||
end
|
||||
end
|
||||
|
||||
context "using 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 "on approval" do
|
||||
setup do
|
||||
@post = create(:post, tag_string: "foo aaa")
|
||||
|
||||
Reference in New Issue
Block a user