From 82b226712f9463dbded3ce895f73487921ad9ac1 Mon Sep 17 00:00:00 2001 From: Michael Sofaer and Raphael Sofaer Date: Fri, 24 Dec 2010 09:58:11 -0800 Subject: [PATCH] Posting spec green --- app/models/user.rb | 9 ++------- spec/models/user/posting_spec.rb | 3 ++- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index 29bb19607..3f0cba346 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -149,7 +149,6 @@ class User < ActiveRecord::Base if aspect_ids == "all" || aspect_ids == :all self.aspects else - aspect_ids = [aspect_ids] unless aspect_ids.is_a?(Array) aspects.where(:id => aspect_ids) end end @@ -158,14 +157,10 @@ class User < ActiveRecord::Base #send to the aspects target_aspect_ids = aspects.map {|a| a.id} - #target_contacts = Contact.where(:user_id => self.id, "aspect_memberships target_people = Person.joins( :contacts => :aspect_memberships - ).where(:aspect_memberships => {:aspect_id => target_aspect_ids}) - #target_people = Person.includes(:contacts).where( - # "contacts.user_id" => self.id, - # "contacts.aspect_memberships.aspect_id" => target_aspect_ids, - # "contacts.pending" => false) + ).where(:aspect_memberships => {:aspect_id => target_aspect_ids} + ).select("DISTINCT `people`.*") post_to_hub(post) if post.respond_to?(:public) && post.public push_to_people(post, target_people) diff --git a/spec/models/user/posting_spec.rb b/spec/models/user/posting_spec.rb index 15322f9d3..6392d4f90 100644 --- a/spec/models/user/posting_spec.rb +++ b/spec/models/user/posting_spec.rb @@ -46,7 +46,8 @@ describe User do describe '#aspects_from_ids' do it 'returns a list of all valid aspects a user can post to' do aspect_ids = Aspect.all.map(&:id) - user.aspects_from_ids(aspect_ids).should =~ user.aspects + user.aspects_from_ids(aspect_ids).map{|a| a}.should == + user.aspects.map{|a| a} #Rspec matchers ftw end it "lets you post to your own aspects" do user.aspects_from_ids([aspect.id]).should == [aspect]