Merge pull request #3357 from evazion/feat-soft-post-validations
Post editing: add warning when creating new tags (#3352)
This commit is contained in:
@@ -1568,6 +1568,42 @@ class PostTest < ActiveSupport::TestCase
|
||||
assert_equal("http://www.hentai-foundry.com/pictures/user/AnimeFlux/219123", @post.normalized_source)
|
||||
end
|
||||
end
|
||||
|
||||
context "when validating tags" do
|
||||
should "warn when creating a new general tag" do
|
||||
@post.add_tag("tag")
|
||||
@post.save
|
||||
|
||||
assert_match(/Created 1 new tag: \[\[tag\]\]/, @post.warnings.full_messages.join)
|
||||
end
|
||||
|
||||
should "warn when adding an artist tag without an artist entry" do
|
||||
@post.add_tag("artist:bkub")
|
||||
@post.save
|
||||
|
||||
assert_match(/Artist \[\[bkub\]\] requires an artist entry./, @post.warnings.full_messages.join)
|
||||
end
|
||||
|
||||
should "warn when a tag removal failed due to implications or automatic tags" do
|
||||
ti = FactoryGirl.create(:tag_implication, antecedent_name: "cat", consequent_name: "animal")
|
||||
@post.reload
|
||||
@post.update(old_tag_string: @post.tag_string, tag_string: "chen_(cosplay) chen cosplay cat animal")
|
||||
@post.reload
|
||||
@post.update(old_tag_string: @post.tag_string, tag_string: "chen_(cosplay) chen cosplay cat -cosplay")
|
||||
|
||||
assert_match(/\[\[animal\]\] and \[\[cosplay\]\] could not be removed./, @post.warnings.full_messages.join)
|
||||
end
|
||||
|
||||
should "warn when a post from a known source is missing an artist tag" do
|
||||
post = FactoryGirl.build(:post, source: "https://www.pixiv.net/member_illust.php?mode=medium&illust_id=65985331")
|
||||
post.save
|
||||
assert_match(/Artist tag is required/, post.warnings.full_messages.join)
|
||||
end
|
||||
|
||||
should "warn when missing a copyright tag" do
|
||||
assert_match(/Copyright tag is required/, @post.warnings.full_messages.join)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user