tag change notices: use cache instead of using redis directly.
This commit is contained in:
@@ -37,28 +37,27 @@ class BulkUpdateRequestTest < ActiveSupport::TestCase
|
||||
|
||||
context "#update_notice" do
|
||||
setup do
|
||||
@mock_redis = MockRedis.new
|
||||
@forum_topic = FactoryBot.create(:forum_topic)
|
||||
TagChangeNoticeService.stubs(:redis_client).returns(@mock_redis)
|
||||
end
|
||||
|
||||
should "update redis" do
|
||||
should "update the cache" do
|
||||
@script = "create alias aaa -> 000\n" +
|
||||
"create implication bbb -> 111\n" +
|
||||
"remove alias ccc -> 222\n" +
|
||||
"remove implication ddd -> 333\n" +
|
||||
"mass update eee -> 444\n"
|
||||
FactoryBot.create(:bulk_update_request, script: @script, forum_topic: @forum_topic)
|
||||
assert_equal(@forum_topic.id.to_s, @mock_redis.get("tcn:aaa"))
|
||||
assert_equal(@forum_topic.id.to_s, @mock_redis.get("tcn:000"))
|
||||
assert_equal(@forum_topic.id.to_s, @mock_redis.get("tcn:bbb"))
|
||||
assert_equal(@forum_topic.id.to_s, @mock_redis.get("tcn:111"))
|
||||
assert_equal(@forum_topic.id.to_s, @mock_redis.get("tcn:ccc"))
|
||||
assert_equal(@forum_topic.id.to_s, @mock_redis.get("tcn:222"))
|
||||
assert_equal(@forum_topic.id.to_s, @mock_redis.get("tcn:ddd"))
|
||||
assert_equal(@forum_topic.id.to_s, @mock_redis.get("tcn:333"))
|
||||
assert_equal(@forum_topic.id.to_s, @mock_redis.get("tcn:eee"))
|
||||
assert_equal(@forum_topic.id.to_s, @mock_redis.get("tcn:444"))
|
||||
|
||||
assert_equal(@forum_topic.id, Cache.get("tcn:aaa"))
|
||||
assert_equal(@forum_topic.id, Cache.get("tcn:000"))
|
||||
assert_equal(@forum_topic.id, Cache.get("tcn:bbb"))
|
||||
assert_equal(@forum_topic.id, Cache.get("tcn:111"))
|
||||
assert_equal(@forum_topic.id, Cache.get("tcn:ccc"))
|
||||
assert_equal(@forum_topic.id, Cache.get("tcn:222"))
|
||||
assert_equal(@forum_topic.id, Cache.get("tcn:ddd"))
|
||||
assert_equal(@forum_topic.id, Cache.get("tcn:333"))
|
||||
assert_equal(@forum_topic.id, Cache.get("tcn:eee"))
|
||||
assert_equal(@forum_topic.id, Cache.get("tcn:444"))
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -71,14 +71,12 @@ class TagAliasTest < ActiveSupport::TestCase
|
||||
|
||||
context "#update_notice" do
|
||||
setup do
|
||||
@mock_redis = MockRedis.new
|
||||
@forum_topic = FactoryBot.create(:forum_topic)
|
||||
TagChangeNoticeService.stubs(:redis_client).returns(@mock_redis)
|
||||
end
|
||||
|
||||
should "update redis" do
|
||||
should "update the cache" do
|
||||
FactoryBot.create(:tag_alias, antecedent_name: "aaa", consequent_name: "bbb", skip_secondary_validations: true, forum_topic: @forum_topic)
|
||||
assert_equal(@forum_topic.id.to_s, @mock_redis.get("tcn:aaa"))
|
||||
assert_equal(@forum_topic.id, Cache.get("tcn:aaa"))
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -67,14 +67,12 @@ class TagImplicationTest < ActiveSupport::TestCase
|
||||
|
||||
context "#update_notice" do
|
||||
setup do
|
||||
@mock_redis = MockRedis.new
|
||||
@forum_topic = FactoryBot.create(:forum_topic)
|
||||
TagChangeNoticeService.stubs(:redis_client).returns(@mock_redis)
|
||||
end
|
||||
|
||||
should "update redis" do
|
||||
should "update the cache" do
|
||||
FactoryBot.create(:tag_implication, antecedent_name: "aaa", consequent_name: "bbb", skip_secondary_validations: true, forum_topic: @forum_topic)
|
||||
assert_equal(@forum_topic.id.to_s, @mock_redis.get("tcn:aaa"))
|
||||
assert_equal(@forum_topic.id, Cache.get("tcn:aaa"))
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user