diff --git a/app/models/tag.rb b/app/models/tag.rb index 830f7820b..b0a89e21f 100644 --- a/app/models/tag.rb +++ b/app/models/tag.rb @@ -394,6 +394,9 @@ class Tag < ActiveRecord::Base q[:pool] = "none" elsif $2.downcase == "any" q[:pool] = "any" + elsif $2.include?("*") + pools = Pool.name_matches($2).all(:select => "id", :limit => Danbooru.config.tag_query_limit, :order => "post_count DESC") + q[:tags][:include] += pools.map!{|pool| "pool:#{pool.id}"} else q[:tags][:related] << "pool:#{Pool.name_to_id($2)}" end diff --git a/test/unit/post_test.rb b/test/unit/post_test.rb index 766dbae3f..36a4595fb 100644 --- a/test/unit/post_test.rb +++ b/test/unit/post_test.rb @@ -1124,6 +1124,19 @@ class PostTest < ActiveSupport::TestCase assert_equal(post1.id, relation.first.id) end + should "return posts for the metatag with a wildcard" do + post1 = FactoryGirl.create(:post) + post2 = FactoryGirl.create(:post) + post3 = FactoryGirl.create(:post) + pool1 = FactoryGirl.create(:pool, :name => "test_a") + pool2 = FactoryGirl.create(:pool, :name => "test_b") + post1.add_pool!(pool1) + post3.add_pool!(pool2) + relation = Post.tag_match("pool:test*") + assert_equal(2, relation.count) + assert_equal([post3.id, post1.id], relation.all.map!(&:id)) + end + should "return posts for the metatag" do second_user = FactoryGirl.create(:user) post1 = FactoryGirl.create(:post, :uploader => CurrentUser.user)