down to 2 failures in postgres

This commit is contained in:
danielgrippi 2011-08-17 16:51:34 -07:00
parent 57ee4cd8a9
commit a99e69edd6
4 changed files with 18 additions and 6 deletions

View file

@ -47,15 +47,26 @@ class Services::Facebook < Service
if postgres?
# Take the naive approach to inserting our new visibilities for now.
data.each do |su|
su.save
if existing = ServiceUser.find_by_uid(su.uid)
update_hash = OVERRIDE_FIELDS_ON_FB_UPDATE.inject({}) do |acc, element|
acc[element] = su.send(element)
acc
end
existing.update_attributes(update_hash)
else
su.save
end
end
else
ServiceUser.import(data, :on_duplicate_key_update => [:updated_at, :contact_id, :person_id, :request_id, :invitation_id, :photo_url, :name, :username])
ServiceUser.import(data, :on_duplicate_key_update => OVERRIDE_FIELDS_ON_FB_UPDATE + [:updated_at])
end
end
private
OVERRIDE_FIELDS_ON_FB_UPDATE = [:contact_id, :person_id, :request_id, :invitation_id, :photo_url, :name, :username]
def prevent_service_users_from_being_empty
if self.service_users.blank?
self.save_friends

View file

@ -59,7 +59,7 @@ describe ContactsController do
it 'will return the contacts for multiple aspects' do
get :index, :aspect_ids => bob.aspect_ids, :format => 'json'
assigns[:people].should == bob.contacts.map(&:person)
assigns[:people].map(&:id).should =~ bob.contacts.map{|c| c.person.id}
response.should be_success
end
@ -73,7 +73,7 @@ describe ContactsController do
aspect.contacts << bob.contact_for(eve.person)
get :index, :format => 'json', :aspect_ids => bob.aspect_ids
assigns[:people].map{|p| p.id}.uniq.should == assigns[:people].map{|p| p.id}
assigns[:people].should == bob.contacts.map(&:person)
assigns[:people].map(&:id).should =~ bob.contacts.map{|c| c.person.id}
end
end

View file

@ -272,6 +272,7 @@ describe 'a user receives a post' do
post_in_db.comments.should == []
receive_with_zord(bob, alice.person, @xml)
post_in_db.comments(true).first.author.should == remote_person
end
end

View file

@ -69,12 +69,12 @@ JSON
it 'attaches local models' do
@service.save_friends
@service.service_users.first.person.should == @user2.person
@service.service_users.where(:uid => @user2_fb_id).first.person.should == @user2.person
end
it 'overwrites local model information' do
@service.save_friends
su = @service.service_users.first
su = @service.service_users.where(:uid => @user2_fb_id).first
su.person.should == @user2.person
su.contact.should == nil