Fix #4129: Remove tag alias caching.

This commit is contained in:
evazion
2019-08-10 21:35:38 -05:00
parent 96b28a77e7
commit c7bcce429e
4 changed files with 11 additions and 56 deletions

View File

@@ -16,17 +16,13 @@ class TagAliasCorrectionTest < ActiveSupport::TestCase
CurrentUser.ip_addr = nil
end
context "with a bad cache and post counts" do
context "with a bad post count" do
setup do
Cache.delete("ta:#{Cache.hash('bbb')}")
Cache.put("ta:#{Cache.hash('aaa')}", "zzz")
Tag.where(:name => "aaa").update_all("post_count = -3")
@correction = TagAliasCorrection.new(@tag_alias.id)
end
should "have the correct statistics hash" do
assert_equal("zzz", @correction.statistics_hash["antecedent_cache"])
assert_nil(@correction.statistics_hash["consequent_cache"])
assert_equal(-3, @correction.statistics_hash["antecedent_count"])
assert_equal(1, @correction.statistics_hash["consequent_count"])
end
@@ -44,11 +40,6 @@ class TagAliasCorrectionTest < ActiveSupport::TestCase
context "that is fixed" do
setup do
@correction.fix!
TagAlias.to_aliased(["aaa"])
end
should "now have the correct cache" do
assert_equal("bbb", Cache.get("ta:#{Cache.hash('aaa')}"))
end
should "now have the correct count" do

View File

@@ -106,22 +106,14 @@ class TagAliasTest < ActiveSupport::TestCase
end
should "convert a tag to its normalized version" do
tag1 = FactoryBot.create(:tag, :name => "aaa")
tag2 = FactoryBot.create(:tag, :name => "bbb")
ta = FactoryBot.create(:tag_alias, :antecedent_name => "aaa", :consequent_name => "bbb")
normalized_tags = TagAlias.to_aliased(["aaa", "ccc"])
assert_equal(["bbb", "ccc"], normalized_tags.sort)
end
tag1 = create(:tag, name: "aaa")
tag2 = create(:tag, name: "bbb")
ta = create(:tag_alias, antecedent_name: "aaa", consequent_name: "bbb")
should "update the cache" do
tag1 = FactoryBot.create(:tag, :name => "aaa")
tag2 = FactoryBot.create(:tag, :name => "bbb")
ta = FactoryBot.create(:tag_alias, :antecedent_name => "aaa", :consequent_name => "bbb")
assert_nil(Cache.get("ta:#{Cache.hash("aaa")}"))
TagAlias.to_aliased(["aaa"])
assert_equal("bbb", Cache.get("ta:#{Cache.hash("aaa")}"))
ta.destroy
assert_nil(Cache.get("ta:#{Cache.hash("aaa")}"))
assert_equal(["bbb"], TagAlias.to_aliased("aaa"))
assert_equal(["bbb", "ccc"], TagAlias.to_aliased(["aaa", "ccc"]))
assert_equal(["ccc", "bbb"], TagAlias.to_aliased(["ccc", "bbb"]))
assert_equal(["bbb", "bbb"], TagAlias.to_aliased(["aaa", "aaa"]))
end
context "saved searches" do