diff --git a/app/models/invitation.rb b/app/models/invitation.rb index bb86f6116..078b18d56 100644 --- a/app/models/invitation.rb +++ b/app/models/invitation.rb @@ -92,4 +92,12 @@ class Invitation < ActiveRecord::Base destroy if contact contact end + + def recipient_identifier + if recipient.invitation_service == 'email' + recipient.invitation_identifier + elsif recipient.invitation_service == 'facebook' + ServiceUser.where(:uid => recipient.invitation_identifier).first.name + end + end end diff --git a/app/views/invitations/new.html.haml b/app/views/invitations/new.html.haml index 89a086c7e..5977375c7 100644 --- a/app/views/invitations/new.html.haml +++ b/app/views/invitations/new.html.haml @@ -36,11 +36,12 @@ %p = invite.submit t('.send_an_invitation') - - if !@sent_invitations.empty? + - unless @sent_invitations.empty? .span-6.last #already_invited_pane %h4 = t('.already_invited') - for invitation in @sent_invitations - = invitation.recipient.email + = invitation.recipient_identifier = link_to t('.resend'), invitation_resend_path(invitation), :confirm => t('are_you_sure') + %br diff --git a/spec/models/invitation_spec.rb b/spec/models/invitation_spec.rb index 65629c2ec..929868ad6 100644 --- a/spec/models/invitation_spec.rb +++ b/spec/models/invitation_spec.rb @@ -21,7 +21,7 @@ describe Invitation do end it 'is valid' do @invitation.sender.should == user - @invitation.recipient.should == eve + @invitation.recipient.should == eve @invitation.aspect.should == aspect @invitation.should be_valid end @@ -323,5 +323,20 @@ describe Invitation do }.should change(Contact, :count).by(2) end end + + describe '#recipient_identifier' do + it 'calls email if the invitation_service is email' do + alice.invite_user(aspect.id, 'email', "a@a.com", "") + invitation = alice.reload.invitations_from_me.first + invitation.recipient_identifier.should == 'a@a.com' + end + it 'gets the name if the invitation_service is facebook' 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", '') + invitation = alice.reload.invitations_from_me.first + invitation.recipient_identifier.should == "Remote User" + end + end end