MS SM fix ajax_stream?

This commit is contained in:
Maxwell Salzberg 2011-10-15 21:49:17 -07:00
parent ea700716ab
commit e1aa709c85
2 changed files with 27 additions and 13 deletions

View file

@ -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

View file

@ -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))