Posting spec green
This commit is contained in:
parent
331e6645c6
commit
82b226712f
2 changed files with 4 additions and 8 deletions
|
|
@ -149,7 +149,6 @@ class User < ActiveRecord::Base
|
||||||
if aspect_ids == "all" || aspect_ids == :all
|
if aspect_ids == "all" || aspect_ids == :all
|
||||||
self.aspects
|
self.aspects
|
||||||
else
|
else
|
||||||
aspect_ids = [aspect_ids] unless aspect_ids.is_a?(Array)
|
|
||||||
aspects.where(:id => aspect_ids)
|
aspects.where(:id => aspect_ids)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -158,14 +157,10 @@ class User < ActiveRecord::Base
|
||||||
#send to the aspects
|
#send to the aspects
|
||||||
target_aspect_ids = aspects.map {|a| a.id}
|
target_aspect_ids = aspects.map {|a| a.id}
|
||||||
|
|
||||||
#target_contacts = Contact.where(:user_id => self.id, "aspect_memberships
|
|
||||||
target_people = Person.joins(
|
target_people = Person.joins(
|
||||||
:contacts => :aspect_memberships
|
:contacts => :aspect_memberships
|
||||||
).where(:aspect_memberships => {:aspect_id => target_aspect_ids})
|
).where(:aspect_memberships => {:aspect_id => target_aspect_ids}
|
||||||
#target_people = Person.includes(:contacts).where(
|
).select("DISTINCT `people`.*")
|
||||||
# "contacts.user_id" => self.id,
|
|
||||||
# "contacts.aspect_memberships.aspect_id" => target_aspect_ids,
|
|
||||||
# "contacts.pending" => false)
|
|
||||||
|
|
||||||
post_to_hub(post) if post.respond_to?(:public) && post.public
|
post_to_hub(post) if post.respond_to?(:public) && post.public
|
||||||
push_to_people(post, target_people)
|
push_to_people(post, target_people)
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,8 @@ describe User do
|
||||||
describe '#aspects_from_ids' do
|
describe '#aspects_from_ids' do
|
||||||
it 'returns a list of all valid aspects a user can post to' do
|
it 'returns a list of all valid aspects a user can post to' do
|
||||||
aspect_ids = Aspect.all.map(&:id)
|
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
|
end
|
||||||
it "lets you post to your own aspects" do
|
it "lets you post to your own aspects" do
|
||||||
user.aspects_from_ids([aspect.id]).should == [aspect]
|
user.aspects_from_ids([aspect.id]).should == [aspect]
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue