From faa04513808b08b79ab22dd609e323a875f53580 Mon Sep 17 00:00:00 2001 From: Ilya Zhitomirskiy <iz268@nyu.edu> Date: Fri, 23 Sep 2011 09:59:05 -0700 Subject: [PATCH] Revert "not passing in by members of if it wasn't passed into the stream" This reverts commit ff1cb665ed88dcdd90e3198611b75baa62ef0bbb. --- lib/aspect_stream.rb | 9 ++-- spec/lib/aspect_stream_spec.rb | 77 +++++++++++++--------------------- 2 files changed, 34 insertions(+), 52 deletions(-) diff --git a/lib/aspect_stream.rb b/lib/aspect_stream.rb index c1b538877d..4d5ea5be5a 100644 --- a/lib/aspect_stream.rb +++ b/lib/aspect_stream.rb @@ -42,11 +42,10 @@ class AspectStream # @return [ActiveRecord::Association<Post>] AR association of posts def posts # NOTE(this should be something like Post.all_for_stream(@user, aspect_ids, {}) that calls visible_posts - opts = {:type => ['StatusMessage', 'Reshare', 'ActivityStreams::Photo'], - :order => "#{@order} DESC", - :max_time => @max_time} - opts[:by_members_of] = aspect_ids unless (@inputted_aspect_ids == []) - @posts ||= @user.visible_posts(opts + @posts ||= @user.visible_posts(:by_members_of => aspect_ids, + :type => ['StatusMessage', 'Reshare', 'ActivityStreams::Photo'], + :order => "#{@order} DESC", + :max_time => @max_time ).includes(:mentions => {:person => :profile}, :author => :profile) end diff --git a/spec/lib/aspect_stream_spec.rb b/spec/lib/aspect_stream_spec.rb index 6a3b8ba534..8fd0a860d7 100644 --- a/spec/lib/aspect_stream_spec.rb +++ b/spec/lib/aspect_stream_spec.rb @@ -5,67 +5,50 @@ require 'aspect_stream' describe AspectStream do - #describe '#aspects' do - # it 'queries the user given initialized aspect ids' do - # alice = stub.as_null_object - # stream = AspectStream.new(alice, [1,2,3]) + describe '#aspects' do + it 'queries the user given initialized aspect ids' do + alice = stub.as_null_object + stream = AspectStream.new(alice, [1,2,3]) - # alice.aspects.should_receive(:where) - # stream.aspects - # end + alice.aspects.should_receive(:where) + stream.aspects + end - # it "returns all the user's aspects if no aspect ids are specified" do - # alice = stub.as_null_object - # stream = AspectStream.new(alice, []) + it "returns all the user's aspects if no aspect ids are specified" do + alice = stub.as_null_object + stream = AspectStream.new(alice, []) - # alice.aspects.should_not_receive(:where) - # stream.aspects - # end + alice.aspects.should_not_receive(:where) + stream.aspects + end - # it 'filters aspects given a user' do - # alice = stub(:aspects => [stub(:id => 1)]) - # alice.aspects.stub(:where).and_return(alice.aspects) - # stream = AspectStream.new(alice, [1,2,3]) + it 'filters aspects given a user' do + alice = stub(:aspects => [stub(:id => 1)]) + alice.aspects.stub(:where).and_return(alice.aspects) + stream = AspectStream.new(alice, [1,2,3]) - # stream.aspects.should == alice.aspects - # end - #end + stream.aspects.should == alice.aspects + end + end - #describe '#aspect_ids' do - # it 'maps ids from aspects' do - # alice = stub.as_null_object - # aspects = stub.as_null_object + describe '#aspect_ids' do + it 'maps ids from aspects' do + alice = stub.as_null_object + aspects = stub.as_null_object - # stream = AspectStream.new(alice, [1,2]) + stream = AspectStream.new(alice, [1,2]) - # stream.should_receive(:aspects).and_return(aspects) - # aspects.should_receive(:map) - # stream.aspect_ids - # end - #end + stream.should_receive(:aspects).and_return(aspects) + aspects.should_receive(:map) + stream.aspect_ids + end + end describe '#posts' do before do @alice = stub.as_null_object end - it 'calls visible posts with blank by_members_of if called with all aspects' do - stream = AspectStream.new(@alice, []) - stream.stub(:aspect_ids).and_return([1,2]) - - @alice.stub(:visible_posts).and_return(stub.as_null_object) - @alice.should_not_receive(:visible_posts).with(hash_including(:by_members_of => anything)).and_return(stub.as_null_object) - stream.posts - end - - it 'calls visible posts with by_members_of if with aspects are filtered' do - stream = AspectStream.new(@alice, [1,2]) - stream.stub(:aspect_ids).and_return([1]) - - @alice.should_receive(:visible_posts).with(hash_including(:by_members_of => [1])).and_return(stub.as_null_object) - stream.posts - end - it 'calls visible posts for the given user' do stream = AspectStream.new(@alice, [1,2]) -- GitLab