Posting spec green

This commit is contained in:
Michael Sofaer and Raphael Sofaer 2010-12-24 09:58:11 -08:00
parent 331e6645c6
commit 82b226712f
2 changed files with 4 additions and 8 deletions

View file

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

View file

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