pools: allow searching pools by post tags.

Find all pools containing at least one post tagged 'translated':

    https://danbooru.donmai.us/pools?search[post_tags_match]=translated
This commit is contained in:
evazion
2019-09-06 17:54:07 -05:00
parent a9b7503aa7
commit 886ee16911
3 changed files with 30 additions and 0 deletions

View File

@@ -78,6 +78,18 @@ class PoolTest < ActiveSupport::TestCase
assert_equal([@pool1.id], Pool.search(post_id_count: 2).pluck(:id))
end
should "find pools by post tags" do
@pool1 = create(:pool, name: "pool1")
@pool2 = create(:pool, name: "pool2")
@post1 = create(:post, tag_string: "pool:pool1 bkub")
@post2 = create(:post, tag_string: "pool:pool1 fumimi")
@post3 = create(:post, tag_string: "pool:pool2 bkub fumimi")
assert_equal([@pool2.id, @pool1.id], Pool.search(post_tags_match: "bkub").pluck(:id))
assert_equal([@pool2.id, @pool1.id], Pool.search(post_tags_match: "fumimi").pluck(:id))
assert_equal([@pool2.id], Pool.search(post_tags_match: "bkub fumimi").pluck(:id))
end
end
context "Creating a pool" do