From c3dc3d103bbca5a2693fb26b1fe59cb72d1ded55 Mon Sep 17 00:00:00 2001 From: Maxwell Salzberg Date: Fri, 4 Nov 2011 18:19:37 -0700 Subject: [PATCH] include post author in participats --- lib/diaspora/shareable.rb | 2 +- spec/models/post_spec.rb | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/diaspora/shareable.rb b/lib/diaspora/shareable.rb index b7acf69e6..4ffd09b19 100644 --- a/lib/diaspora/shareable.rb +++ b/lib/diaspora/shareable.rb @@ -111,7 +111,7 @@ module Diaspora def participants @participants ||= lambda do share_type = self.class.base_class.to_s - people = [] + people = [self.author] if self.respond_to? :comments people += Person.joins(:comments).where(:comments => {:commentable_id => self.id, :commentable_type => share_type}).all end diff --git a/spec/models/post_spec.rb b/spec/models/post_spec.rb index 64c512953..ddf5dda54 100644 --- a/spec/models/post_spec.rb +++ b/spec/models/post_spec.rb @@ -196,13 +196,19 @@ describe Post do end describe '#participants' do + it 'includes the post author' do + status = Factory(:status_message, :author => bob.person, :public => true) + status.participants.map(&:id).should == [bob.person.id] + end + it 'only returns the people that commented and liked the post' do status = Factory(:status_message, :author => bob.person, :public => true) alice.comment('too', :post => status) eve.like(true, :target => status) - status.participants.map(&:id).should =~ [alice, eve].map{|x| x.person.id} + status.participants.map(&:id).should =~ [alice, eve, bob].map{|x| x.person.id} end + end describe '#comments' do