Merge pull request #3389 from evazion/fix-3387

Fix #3387: Safebooru: Two tag searches fail for members.
This commit is contained in:
Albert Yi
2017-11-20 11:39:50 -08:00
committed by GitHub
3 changed files with 23 additions and 1 deletions

View File

@@ -2292,6 +2292,14 @@ class PostTest < ActiveSupport::TestCase
end
end
should "not count free tags against the user's search limit" do
post1 = FactoryGirl.create(:post, tag_string: "aaa bbb rating:s")
Danbooru.config.expects(:is_unlimited_tag?).with("rating:s").once.returns(true)
Danbooru.config.expects(:is_unlimited_tag?).with(anything).twice.returns(false)
assert_tag_match([post1], "aaa bbb rating:s")
end
should "succeed for exclusive tag searches with no other tag" do
post1 = FactoryGirl.create(:post, :rating => "s", :tag_string => "aaa")
assert_nothing_raised do
@@ -2425,6 +2433,15 @@ class PostTest < ActiveSupport::TestCase
assert_equal(1, Post.fast_count(""))
end
should "not fail for a two tag search by a member" do
post1 = FactoryGirl.create(:post, tag_string: "aaa bbb rating:s")
post2 = FactoryGirl.create(:post, tag_string: "aaa bbb rating:e")
Danbooru.config.expects(:is_unlimited_tag?).with("rating:s").once.returns(true)
Danbooru.config.expects(:is_unlimited_tag?).with(anything).twice.returns(false)
assert_equal(1, Post.fast_count("aaa bbb"))
end
should "set the value in cache" do
Post.expects(:set_count_in_cache).with("rating:s", kind_of(Integer)).once
Post.fast_count("")