diff --git a/app/services/random_topic_selector.rb b/app/services/random_topic_selector.rb index bb71d251e9..003dcc629e 100644 --- a/app/services/random_topic_selector.rb +++ b/app/services/random_topic_selector.rb @@ -77,10 +77,6 @@ class RandomTopicSelector results end - def self.clear_cache! - $redis.keys('random_topic_cache*').each{|k| $redis.del k} - end - def self.cache_key(category=nil) "random_topic_cache_#{category.try(:id)}" end diff --git a/spec/components/topic_query_spec.rb b/spec/components/topic_query_spec.rb index 6fe6552615..c50319ff27 100644 --- a/spec/components/topic_query_spec.rb +++ b/spec/components/topic_query_spec.rb @@ -642,9 +642,12 @@ describe TopicQuery do end context 'suggested_for' do + def clear_cache! + $redis.keys('random_topic_cache*').each{|k| $redis.del k} + end before do - RandomTopicSelector.clear_cache! + clear_cache! end context 'when anonymous' do @@ -674,7 +677,7 @@ describe TopicQuery do let(:suggested_topics) { tt = topic # lets clear cache once category is created - working around caching is hard - RandomTopicSelector.clear_cache! + clear_cache! topic_query.list_suggested_for(tt).topics.map{|t| t.id} } @@ -691,11 +694,11 @@ describe TopicQuery do SiteSetting.suggested_topics_max_days_old = 1365 tt = topic - RandomTopicSelector.clear_cache! + clear_cache! expect(topic_query.list_suggested_for(tt).topics.length).to eq(2) SiteSetting.suggested_topics_max_days_old = 365 - RandomTopicSelector.clear_cache! + clear_cache! expect(topic_query.list_suggested_for(tt).topics.length).to eq(1) end