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