diff --git a/lib/stream/aspect.rb b/lib/stream/aspect.rb index 29b016671..2f6891fd3 100644 --- a/lib/stream/aspect.rb +++ b/lib/stream/aspect.rb @@ -72,11 +72,7 @@ class Stream::Aspect < Stream::Base # # @return [Boolean] see #for_all_aspects? def ajax_stream? - if AppConfig[:redis_cache] - true - else - false - end + !AppConfig[:redis_cache] && for_all_aspects? end # The title that will display at the top of the stream's diff --git a/spec/lib/stream/aspect_spec.rb b/spec/lib/stream/aspect_spec.rb index d4414329f..207c5fda0 100644 --- a/spec/lib/stream/aspect_spec.rb +++ b/spec/lib/stream/aspect_spec.rb @@ -134,20 +134,38 @@ describe Stream::Aspect do describe '.ajax_stream?' do before do + @original_value = AppConfig[:redis_cache] @stream = Stream::Aspect.new(stub, stub) end - it 'is true stream is for all aspects?' do - pending - @stream.stub(:for_all_aspects?).and_return(true) - @stream.ajax_stream?.should be_true + + after do + AppConfig[:redis_cache] = @original_value end - it 'is false if it is not for all aspects' do - pending - @stream.stub(:for_all_aspects?).and_return(false) - @stream.ajax_stream?.should be_false + context 'if we are not caching with redis' do + before do + AppConfig[:redis_cache] = false + end + + it 'is true if stream is for all aspects?' do + @stream.stub(:for_all_aspects?).and_return(true) + @stream.ajax_stream?.should be_true + end + + it 'is false if it is not for all aspects' do + @stream.stub(:for_all_aspects?).and_return(false) + @stream.ajax_stream?.should be_false + end + end + + context 'if we are caching with redis' do + it 'returns false' do + AppConfig[:redis_cache] = true + @stream.ajax_stream?.should be_false + end end end + describe 'shared behaviors' do before do @stream = Stream::Aspect.new(alice, alice.aspects.map(&:id))