improve erraticly failing spec

This commit is contained in:
Sam 2018-05-23 08:39:15 +10:00
parent 8e9531657a
commit 45f65859c9
2 changed files with 10 additions and 1 deletions

View File

@ -91,4 +91,8 @@ class RandomTopicSelector
"random_topic_cache_#{category&.id}"
end
def self.clear_cache!
$redis.delete_prefixed(cache_key)
end
end

View File

@ -3,7 +3,12 @@ require 'rails_helper'
describe TopicViewSerializer do
def serialize_topic(topic, user_arg)
topic_view = TopicView.new(topic.id, user_arg)
described_class.new(topic_view, scope: Guardian.new(user_arg), root: false).as_json
TopicViewSerializer.new(topic_view, scope: Guardian.new(user_arg), root: false).as_json
end
before do
# ensure no suggested ids are cached cause that can muck up suggested
RandomTopicSelector.clear_cache!
end
let(:topic) { Fabricate(:topic) }