Fix Post.fast_count("pool:1537") == 0 (fixup 134958d1).
Fixup for a bug in 134958d1. `Post.fast_count("pool:1537")` still
returned zero because `Tag.is_simple_tag?` incorrectly parsed
"pool:1537" as a simple tag, so Post.fast_count still looked for it in
the tags table and found the empty "pool:1537" tag.
This commit is contained in:
@@ -2405,6 +2405,13 @@ class PostTest < ActiveSupport::TestCase
|
||||
|
||||
assert_equal(100, Post.fast_count("score:42"))
|
||||
end
|
||||
|
||||
should "return the correct cached count for a pool:<id> search" do
|
||||
FactoryGirl.build(:tag, name: "pool:1234", post_count: -100).save(validate: false)
|
||||
Post.set_count_in_cache("pool:1234", 100)
|
||||
|
||||
assert_equal(100, Post.fast_count("pool:1234"))
|
||||
end
|
||||
end
|
||||
|
||||
context "a multi-tag search" do
|
||||
|
||||
@@ -158,6 +158,28 @@ class TagTest < ActiveSupport::TestCase
|
||||
Tag.expects(:normalize_tags_in_query).returns(nil)
|
||||
assert_equal(["acb"], Tag.parse_query("a*b")[:tags][:include])
|
||||
end
|
||||
|
||||
should "parse single tags correctly" do
|
||||
assert_equal(true, Tag.is_single_tag?("foo"))
|
||||
assert_equal(true, Tag.is_single_tag?("-foo"))
|
||||
assert_equal(true, Tag.is_single_tag?("~foo"))
|
||||
assert_equal(true, Tag.is_single_tag?("foo*"))
|
||||
assert_equal(true, Tag.is_single_tag?("fav:1234"))
|
||||
assert_equal(true, Tag.is_single_tag?("pool:1234"))
|
||||
assert_equal(true, Tag.is_single_tag?('source:"foo bar baz"'))
|
||||
assert_equal(false, Tag.is_single_tag?("foo bar"))
|
||||
end
|
||||
|
||||
should "parse simple tags correctly" do
|
||||
assert_equal(true, Tag.is_simple_tag?("foo"))
|
||||
assert_equal(false, Tag.is_simple_tag?("-foo"))
|
||||
assert_equal(false, Tag.is_simple_tag?("~foo"))
|
||||
assert_equal(false, Tag.is_simple_tag?("foo*"))
|
||||
assert_equal(false, Tag.is_simple_tag?("fav:1234"))
|
||||
assert_equal(false, Tag.is_simple_tag?("pool:1234"))
|
||||
assert_equal(false, Tag.is_simple_tag?('source:"foo bar baz"'))
|
||||
assert_equal(false, Tag.is_simple_tag?("foo bar"))
|
||||
end
|
||||
end
|
||||
|
||||
context "A tag" do
|
||||
|
||||
Reference in New Issue
Block a user