From a26853c1a48621c036ebc223f66eb1ccbf87efcd Mon Sep 17 00:00:00 2001
From: Sam <sam.saffron@gmail.com>
Date: Thu, 5 Mar 2015 17:47:34 +1100
Subject: [PATCH] try to work around caching bug in spec

---
 spec/components/topic_query_spec.rb | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/spec/components/topic_query_spec.rb b/spec/components/topic_query_spec.rb
index be4df3ae6db..e30cb8de9b5 100644
--- a/spec/components/topic_query_spec.rb
+++ b/spec/components/topic_query_spec.rb
@@ -432,12 +432,13 @@ describe TopicQuery do
 
     context 'when logged in' do
 
-      before do
-        RandomTopicSelector.clear_cache!
-      end
-
       let(:topic) { Fabricate(:topic) }
-      let(:suggested_topics) { topic_query.list_suggested_for(topic).topics.map{|t| t.id} }
+      let(:suggested_topics) {
+        tt = topic
+        # lets clear cache once category is created - working around caching is hard
+        RandomTopicSelector.clear_cache!
+        topic_query.list_suggested_for(tt).topics.map{|t| t.id}
+      }
 
       it "should return empty results when there is nothing to find" do
         expect(suggested_topics).to be_blank