fixed the nil photo_url and the all being called twice in the specs
This commit is contained in:
parent
821703f4d4
commit
32f08ef345
2 changed files with 8 additions and 9 deletions
|
|
@ -87,9 +87,9 @@ describe ServicesController do
|
||||||
@user.services << @service1
|
@user.services << @service1
|
||||||
@person = Factory(:person)
|
@person = Factory(:person)
|
||||||
@user.services.stub!(:where).and_return([@service1])
|
@user.services.stub!(:where).and_return([@service1])
|
||||||
@hash = [ ServiceUser.create(:contact => @user.contact_for(bob.person), :name => "Robert Bobson", :person => bob.person,
|
@hash = [ ServiceUser.create(:contact => @user.contact_for(bob.person), :name => "Robert Bobson", :photo_url => "cdn1.fb.com/pic1.jpg", :person => bob.person,
|
||||||
:service => @service1, :uid => "321" ),
|
:service => @service1, :uid => "321" ),
|
||||||
ServiceUser.create(:name => "Robert Bobson", :service => @service1, :uid => "dsfasdfas")]
|
ServiceUser.create(:name => "Robert Bobson", :photo_url => "cdn1.fb.com/pic1.jpg", :service => @service1, :uid => "dsfasdfas")]
|
||||||
@service1.should_receive(:finder).and_return(@hash)
|
@service1.should_receive(:finder).and_return(@hash)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -58,8 +58,7 @@ JSON
|
||||||
|
|
||||||
describe '#save_friends' do
|
describe '#save_friends' do
|
||||||
it 'requests a friend list' do
|
it 'requests a friend list' do
|
||||||
RestClient.should_receive(:get).with("https://graph.facebook.com/me/friends", {:params =>
|
RestClient.should_receive(:get).with("https://graph.facebook.com/me/friends?fields[]=name&fields[]=picture&access_token=yeah").and_return(@web_mock)
|
||||||
{:fields => ['name', 'id', 'picture'], :access_token => @service.access_token}}).and_return(@web_mock)
|
|
||||||
@service.save_friends
|
@service.save_friends
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -84,21 +83,21 @@ JSON
|
||||||
context 'opts' do
|
context 'opts' do
|
||||||
it 'only local does not return people who are remote' do
|
it 'only local does not return people who are remote' do
|
||||||
@service.save_friends
|
@service.save_friends
|
||||||
@service.finder(:local => true).all.each{|su| su.person.should == @user2.person}
|
@service.finder(:local => true).each{|su| su.person.should == @user2.person}
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does not return people who are remote' do
|
it 'does not return people who are remote' do
|
||||||
@service.save_friends
|
@service.save_friends
|
||||||
@service.finder(:remote => true).all.each{|su| su.person.should be_nil}
|
@service.finder(:remote => true).each{|su| su.person.should be_nil}
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does not return wrong service objects' do
|
it 'does not return wrong service objects' do
|
||||||
su2 = ServiceUser.create(:service => @user2_service, :uid => @user2_fb_id, :name => @user2_fb_name, :photo_url => @user2_fb_photo_url)
|
su2 = ServiceUser.create(:service => @user2_service, :uid => @user2_fb_id, :name => @user2_fb_name, :photo_url => @user2_fb_photo_url)
|
||||||
su2.person.should == @user2.person
|
su2.person.should == @user2.person
|
||||||
|
|
||||||
@service.finder(:local => true).all.each{|su| su.service.should == @service}
|
@service.finder(:local => true).each{|su| su.service.should == @service}
|
||||||
@service.finder(:remote => true).all.each{|su| su.service.should == @service}
|
@service.finder(:remote => true).each{|su| su.service.should == @service}
|
||||||
@service.finder.all.each{|su| su.service.should == @service}
|
@service.finder.each{|su| su.service.should == @service}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue