Post.fast_count: fix incorrect counts for aliased tags.
Revert optimization from a6163258b. Turns out that we have to resolve
aliases in fast_count, otherwise for aliased tags we'll return an empty
count.
Fixes #4156.
This commit is contained in:
@@ -2550,6 +2550,12 @@ class PostTest < ActiveSupport::TestCase
|
||||
end
|
||||
end
|
||||
|
||||
context "an aliased tag" do
|
||||
should "return the count of the consequent tag" do
|
||||
assert_equal(Post.fast_count("aaa"), Post.fast_count("alias"))
|
||||
end
|
||||
end
|
||||
|
||||
context "a single metatag" do
|
||||
should "return the correct cached count" do
|
||||
FactoryBot.build(:tag, name: "score:42", post_count: -100).save(validate: false)
|
||||
|
||||
@@ -61,6 +61,14 @@ class RelatedTagCalculatorTest < ActiveSupport::TestCase
|
||||
assert_equal(%w[1girl 1boy solo], RelatedTagCalculator.similar_tags_for_search("rating:q").pluck(:name))
|
||||
assert_equal(%w[solo 1girl], RelatedTagCalculator.similar_tags_for_search("solo").pluck(:name))
|
||||
end
|
||||
|
||||
should "calculate the similar tags for an aliased tag" do
|
||||
create(:tag_alias, antecedent_name: "rabbit", consequent_name: "bunny")
|
||||
create(:post, tag_string: "bunny dog")
|
||||
create(:post, tag_string: "bunny cat")
|
||||
|
||||
assert_equal(%w[bunny cat dog], RelatedTagCalculator.similar_tags_for_search("rabbit").pluck(:name))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user