Skip to content

Commit

Permalink
Fix resend links in inviter
Browse files Browse the repository at this point in the history
  • Loading branch information
Raphael Sofaer committed Jul 12, 2011
1 parent 98ebb38 commit e30b82d
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
8 changes: 8 additions & 0 deletions app/models/invitation.rb
Expand Up @@ -92,4 +92,12 @@ def share_with!
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
5 changes: 3 additions & 2 deletions app/views/invitations/new.html.haml
Expand Up @@ -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
17 changes: 16 additions & 1 deletion spec/models/invitation_spec.rb
Expand Up @@ -21,7 +21,7 @@
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
Expand Down Expand Up @@ -323,5 +323,20 @@
}.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

0 comments on commit e30b82d

Please sign in to comment.