Remove more refs to aspects.first - should make postgres builds green

This commit is contained in:
Sarah Mei 2011-09-05 19:04:56 -07:00
parent f06b8c7a58
commit 7d10b3fdb0
2 changed files with 26 additions and 24 deletions

View file

@ -12,9 +12,9 @@ describe 'a user receives a post' do
end end
before do before do
@aspect = alice.aspects.first @alices_aspect = alice.aspects.where(:name => "generic").first
@aspect2 = bob.aspects.first @bobs_aspect = bob.aspects.where(:name => "generic").first
@aspect3 = eve.aspects.first @eves_aspect = eve.aspects.where(:name => "generic").first
@contact = alice.contact_for(bob.person) @contact = alice.contact_for(bob.person)
end end
@ -22,7 +22,7 @@ describe 'a user receives a post' do
it 'streams only one message to the everyone aspect when a multi-aspected contacts posts' do it 'streams only one message to the everyone aspect when a multi-aspected contacts posts' do
contact = alice.contact_for(bob.person) contact = alice.contact_for(bob.person)
alice.add_contact_to_aspect(contact, alice.aspects.create(:name => "villains")) alice.add_contact_to_aspect(contact, alice.aspects.create(:name => "villains"))
status = bob.build_post(:status_message, :text => "Users do things", :to => @aspect2.id) status = bob.build_post(:status_message, :text => "Users do things", :to => @bobs_aspect.id)
Diaspora::WebSocket.stub!(:is_connected?).and_return(true) Diaspora::WebSocket.stub!(:is_connected?).and_return(true)
Diaspora::WebSocket.should_receive(:queue_to_user).exactly(:once) Diaspora::WebSocket.should_receive(:queue_to_user).exactly(:once)
zord = Postzord::Receiver.new(alice, :object => status, :person => bob.person) zord = Postzord::Receiver.new(alice, :object => status, :person => bob.person)
@ -30,7 +30,7 @@ describe 'a user receives a post' do
end end
it 'should be able to parse and store a status message from xml' do it 'should be able to parse and store a status message from xml' do
status_message = bob.post :status_message, :text => 'store this!', :to => @aspect2.id status_message = bob.post :status_message, :text => 'store this!', :to => @bobs_aspect.id
xml = status_message.to_diaspora_xml xml = status_message.to_diaspora_xml
bob.delete bob.delete
@ -45,7 +45,7 @@ describe 'a user receives a post' do
num_aspects = alice.aspects.size num_aspects = alice.aspects.size
2.times do |n| 2.times do |n|
status_message = bob.post :status_message, :text => "store this #{n}!", :to => @aspect2.id status_message = bob.post :status_message, :text => "store this #{n}!", :to => @bobs_aspect.id
end end
alice.aspects.size.should == num_aspects alice.aspects.size.should == num_aspects
@ -83,7 +83,7 @@ describe 'a user receives a post' do
it 'notifies users when receiving a mention in a post from a remote user' do it 'notifies users when receiving a mention in a post from a remote user' do
@remote_person = Factory.create(:person, :diaspora_handle => "foobar@foobar.com") @remote_person = Factory.create(:person, :diaspora_handle => "foobar@foobar.com")
Contact.create!(:user => alice, :person => @remote_person, :aspects => [@aspect]) Contact.create!(:user => alice, :person => @remote_person, :aspects => [@alices_aspect])
Notification.should_receive(:notify).with(alice, anything(), @remote_person) Notification.should_receive(:notify).with(alice, anything(), @remote_person)
@ -110,7 +110,7 @@ describe 'a user receives a post' do
context 'update posts' do context 'update posts' do
it 'does not update posts not marked as mutable' do it 'does not update posts not marked as mutable' do
status = alice.post :status_message, :text => "store this!", :to => @aspect.id status = alice.post :status_message, :text => "store this!", :to => @alices_aspect.id
status.text = 'foo' status.text = 'foo'
xml = status.to_diaspora_xml xml = status.to_diaspora_xml
@ -120,7 +120,7 @@ describe 'a user receives a post' do
end end
it 'updates posts marked as mutable' do it 'updates posts marked as mutable' do
photo = alice.post(:photo, :user_file => uploaded_photo, :text => "Original", :to => @aspect.id) photo = alice.post(:photo, :user_file => uploaded_photo, :text => "Original", :to => @alices_aspect.id)
photo.text = 'foo' photo.text = 'foo'
xml = photo.to_diaspora_xml xml = photo.to_diaspora_xml
bob.reload bob.reload
@ -146,9 +146,9 @@ describe 'a user receives a post' do
describe 'post refs' do describe 'post refs' do
before do before do
@status_message = bob.post(:status_message, :text => "hi", :to => @aspect2.id) @status_message = bob.post(:status_message, :text => "hi", :to => @bobs_aspect.id)
alice.reload alice.reload
@aspect.reload @alices_aspect.reload
@contact = alice.contact_for(bob.person) @contact = alice.contact_for(bob.person)
end end
@ -166,7 +166,7 @@ describe 'a user receives a post' do
context 'dependant delete' do context 'dependant delete' do
before do before do
@person = Factory(:person) @person = Factory(:person)
alice.contacts.create(:person => @person, :aspects => [@aspect]) alice.contacts.create(:person => @person, :aspects => [@alices_aspect])
@post = Factory.create(:status_message, :author => @person) @post = Factory.create(:status_message, :author => @person)
@post.post_visibilities.should be_empty @post.post_visibilities.should be_empty
@ -225,8 +225,8 @@ describe 'a user receives a post' do
context 'remote' do context 'remote' do
before do before do
connect_users(alice, @aspect, eve, @aspect3) connect_users(alice, @alices_aspect, eve, @eves_aspect)
@post = alice.post(:status_message, :text => "hello", :to => @aspect.id) @post = alice.post(:status_message, :text => "hello", :to => @alices_aspect.id)
xml = @post.to_diaspora_xml xml = @post.to_diaspora_xml
@ -276,7 +276,7 @@ describe 'a user receives a post' do
context 'local' do context 'local' do
before do before do
@post = alice.post :status_message, :text => "hello", :to => @aspect.id @post = alice.post :status_message, :text => "hello", :to => @alices_aspect.id
xml = @post.to_diaspora_xml xml = @post.to_diaspora_xml
@ -327,7 +327,7 @@ describe 'a user receives a post' do
describe 'salmon' do describe 'salmon' do
let(:post){alice.post :status_message, :text => "hello", :to => @aspect.id} let(:post){alice.post :status_message, :text => "hello", :to => @alices_aspect.id}
let(:salmon){alice.salmon( post )} let(:salmon){alice.salmon( post )}
it 'processes a salmon for a post' do it 'processes a salmon for a post' do
@ -343,7 +343,7 @@ describe 'a user receives a post' do
context 'retractions' do context 'retractions' do
it 'should accept retractions' do it 'should accept retractions' do
message = bob.post(:status_message, :text => "cats", :to => @aspect2.id) message = bob.post(:status_message, :text => "cats", :to => @bobs_aspect.id)
retraction = Retraction.for(message) retraction = Retraction.for(message)
xml = retraction.to_diaspora_xml xml = retraction.to_diaspora_xml

View file

@ -7,14 +7,15 @@ require 'spec_helper'
describe User do describe User do
before do before do
@alices_aspect = alice.aspects.first @alices_aspect = alice.aspects.where(:name => "generic").first
@eves_aspect = eve.aspects.first @eves_aspect = eve.aspects.where(:name => "generic").first
@bobs_aspect = bob.aspects.where(:name => "generic").first
end end
describe "#visible_posts" do describe "#visible_posts" do
it "returns all the posts the user can see" do it "returns all the posts the user can see" do
self_post = alice.post(:status_message, :text => "hi", :to => @alices_aspect.id) self_post = alice.post(:status_message, :text => "hi", :to => @alices_aspect.id)
visible_post = bob.post(:status_message, :text => "hello", :to => bob.aspects.first.id) visible_post = bob.post(:status_message, :text => "hello", :to => @bobs_aspect.id)
dogs = bob.aspects.create(:name => "dogs") dogs = bob.aspects.create(:name => "dogs")
invisible_post = bob.post(:status_message, :text => "foobar", :to => dogs.id) invisible_post = bob.post(:status_message, :text => "foobar", :to => dogs.id)
@ -25,11 +26,12 @@ describe User do
end end
context 'with many posts' do context 'with many posts' do
before do before do
bob.move_contact(eve.person, bob.aspects.first, bob.aspects.create(:name => 'new aspect')) bob.move_contact(eve.person, @bobs_aspect, bob.aspects.create(:name => 'new aspect'))
time_interval = 1000 time_interval = 1000
(1..25).each do |n| (1..25).each do |n|
[alice, bob, eve].each do |u| [alice, bob, eve].each do |u|
post = u.post :status_message, :text => "#{u.username} - #{n}", :to => u.aspects.first.id aspect_to_post = u.aspects.where(:name => "generic").first
post = u.post :status_message, :text => "#{u.username} - #{n}", :to => aspect_to_post.id
post.created_at = post.created_at - time_interval post.created_at = post.created_at - time_interval
post.updated_at = post.updated_at - time_interval post.updated_at = post.updated_at - time_interval
post.save post.save
@ -175,7 +177,7 @@ describe User do
end end
it "returns an empty array when passed an aspect the user doesn't own" do it "returns an empty array when passed an aspect the user doesn't own" do
alice.people_in_aspects([eve.aspects.first]).should == [] alice.people_in_aspects([@eves_aspect]).should == []
end end
end end
end end
@ -234,7 +236,7 @@ describe User do
end end
it 'should return the aspects with given contact' do it 'should return the aspects with given contact' do
alice.aspects_with_person(@connected_person).should == [alice.aspects.first] alice.aspects_with_person(@connected_person).should == [@alices_aspect]
end end
it 'returns multiple aspects if the person is there' do it 'returns multiple aspects if the person is there' do