From 350a4b4f6d082ffb095950eafdc937c277f776ac Mon Sep 17 00:00:00 2001 From: Raphael Sofaer Date: Wed, 10 Aug 2011 16:42:08 -0700 Subject: [PATCH] Fix 500 on invitations new on unknown facebook user... bad solution, maybe we should just delete the offending invitations? --- app/models/invitation.rb | 6 +++++- config/locales/diaspora/en.yml | 1 + spec/models/invitation_spec.rb | 8 ++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/app/models/invitation.rb b/app/models/invitation.rb index 23dcb2c9e..49e172c50 100644 --- a/app/models/invitation.rb +++ b/app/models/invitation.rb @@ -96,7 +96,11 @@ class Invitation < ActiveRecord::Base if recipient.invitation_service == 'email' recipient.invitation_identifier elsif recipient.invitation_service == 'facebook' - ServiceUser.where(:uid => recipient.invitation_identifier).first.name + if su = ServiceUser.where(:uid => recipient.invitation_identifier).first + su.name + else + I18n.t('invitations.a_facebook_user') + end end end end diff --git a/config/locales/diaspora/en.yml b/config/locales/diaspora/en.yml index 50c5c43dd..976ce02ae 100644 --- a/config/locales/diaspora/en.yml +++ b/config/locales/diaspora/en.yml @@ -305,6 +305,7 @@ en: edit: your_account_awaits: "Your account awaits!" accept_your_invitation: "Accept your invitation" + a_facebook_user: "A Facebook user" layouts: header: diff --git a/spec/models/invitation_spec.rb b/spec/models/invitation_spec.rb index c21195247..19c37ffb3 100644 --- a/spec/models/invitation_spec.rb +++ b/spec/models/invitation_spec.rb @@ -337,6 +337,14 @@ describe Invitation do invitation = alice.reload.invitations_from_me.first invitation.recipient_identifier.should == "Remote User" end + it 'does not error if the facebook user is not recorded' do + alice.services << Services::Facebook.new(:uid => "13234895") + alice.reload.services(true).first.service_users.create(:uid => "23526464", :photo_url => 'url', :name => "Remote User") + alice.invite_user(aspect.id, 'facebook', "23526464", '') + alice.services.first.service_users.delete_all + invitation = alice.reload.invitations_from_me.first + invitation.recipient_identifier.should == "A Facebook user" + end end end