Merge branch 'master' into fix-recaptcha
This commit is contained in:
@@ -244,6 +244,11 @@ class CommentTest < ActiveSupport::TestCase
|
||||
@comment.update_attributes({:body => "nope"}, :as => :moderator)
|
||||
end
|
||||
end
|
||||
|
||||
should "credit the moderator as the updater" do
|
||||
@comment.update({ body: "test" }, as: :moderator)
|
||||
assert_equal(@mod.id, @comment.updater_id)
|
||||
end
|
||||
end
|
||||
|
||||
context "that is below the score threshold" do
|
||||
|
||||
@@ -34,8 +34,21 @@ module Moderator
|
||||
ss = FactoryGirl.create(:saved_search, :user => @user, :query => "123 ... 456")
|
||||
tag_batch_change = TagBatchChange.new("...", "bbb", @user.id, "127.0.0.1")
|
||||
tag_batch_change.perform
|
||||
ss.reload
|
||||
assert_equal(%w(123 456 bbb), ss.query.scan(/\S+/).sort)
|
||||
|
||||
assert_equal("123 456 bbb", ss.reload.normalized_query)
|
||||
end
|
||||
|
||||
should "move only saved searches that match the mass update exactly" do
|
||||
ss = FactoryGirl.create(:saved_search, :user => @user, :query => "123 ... 456")
|
||||
tag_batch_change = TagBatchChange.new("1", "bbb", @user.id, "127.0.0.1")
|
||||
tag_batch_change.perform
|
||||
|
||||
assert_equal("... 123 456", ss.reload.normalized_query, "expected '123' to remain unchanged")
|
||||
|
||||
tag_batch_change = TagBatchChange.new("123 456", "789", @user.id, "127.0.0.1")
|
||||
tag_batch_change.perform
|
||||
|
||||
assert_equal("... 789", ss.reload.normalized_query, "expected '123 456' to be changed to '789'")
|
||||
end
|
||||
|
||||
should "raise an error if there is no predicate" do
|
||||
|
||||
@@ -353,6 +353,17 @@ class PostTest < ActiveSupport::TestCase
|
||||
p1.reload
|
||||
assert(p1.has_children?, "Parent should have children")
|
||||
end
|
||||
|
||||
should "clear the has_active_children flag when the 'move favorites' option is set" do
|
||||
user = FactoryGirl.create(:gold_user)
|
||||
p1 = FactoryGirl.create(:post)
|
||||
c1 = FactoryGirl.create(:post, :parent_id => p1.id)
|
||||
c1.add_favorite!(user)
|
||||
|
||||
assert_equal(true, p1.reload.has_active_children?)
|
||||
c1.delete!("test", :move_favorites => true)
|
||||
assert_equal(false, p1.reload.has_active_children?)
|
||||
end
|
||||
end
|
||||
|
||||
context "one child" do
|
||||
@@ -779,6 +790,14 @@ class PostTest < ActiveSupport::TestCase
|
||||
assert(Tag.where(name: "someone_(cosplay)", category: 4).exists?, "expected 'someone_(cosplay)' tag to be created as character")
|
||||
assert(Tag.where(name: "someone", category: 4).exists?, "expected 'someone' tag to be created")
|
||||
end
|
||||
|
||||
should "apply aliases when the character tag is added" do
|
||||
FactoryGirl.create(:tag_alias, antecedent_name: "jim", consequent_name: "james")
|
||||
@post.add_tag("jim_(cosplay)")
|
||||
@post.save
|
||||
|
||||
assert(@post.has_tag?("james"), "expected 'jim' to be aliased to 'james'")
|
||||
end
|
||||
end
|
||||
|
||||
context "for a parent" do
|
||||
@@ -816,6 +835,25 @@ class PostTest < ActiveSupport::TestCase
|
||||
end
|
||||
end
|
||||
|
||||
context "for a favgroup" do
|
||||
setup do
|
||||
@favgroup = FactoryGirl.create(:favorite_group, creator: @user)
|
||||
@post = FactoryGirl.create(:post, :tag_string => "aaa favgroup:#{@favgroup.id}")
|
||||
end
|
||||
|
||||
should "add the post to the favgroup" do
|
||||
assert_equal(1, @favgroup.reload.post_count)
|
||||
assert_equal(true, !!@favgroup.contains?(@post.id))
|
||||
end
|
||||
|
||||
should "remove the post from the favgroup" do
|
||||
@post.update(:tag_string => "-favgroup:#{@favgroup.id}")
|
||||
|
||||
assert_equal(0, @favgroup.reload.post_count)
|
||||
assert_equal(false, !!@favgroup.contains?(@post.id))
|
||||
end
|
||||
end
|
||||
|
||||
context "for a pool" do
|
||||
setup do
|
||||
mock_pool_archive_service!
|
||||
@@ -1549,6 +1587,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
|
||||
|
||||
|
||||
@@ -49,6 +49,7 @@ class PostViewCountServiceTest < ActiveSupport::TestCase
|
||||
|
||||
context "failure" do
|
||||
setup do
|
||||
@date = "2000-01-01"
|
||||
stub_request(:get, "localhost:1234/post_views/rank").with(query: {"date" => @date}).to_return(body: "", status: 400)
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user