Commit a6106180 authored by zhitomirskiyi's avatar zhitomirskiyi

display resend link if already sent invitation in friend finder

parent 906dd8d6
......@@ -52,8 +52,14 @@ class ServicesController < ApplicationController
def inviter
@uid = params[:uid]
if i_id = params[:invitation_id]
invited_user = Invitation.find(i_id).recipient
else
invited_user = current_user.invite_user(params[:aspect_id], params[:provider], @uid)
end
@subject = t('.join_me_on_diaspora')
invited_user = current_user.invite_user(params[:aspect_id], params[:provider], params[:uid])
@message = <<MSG
#{t('.click_link_to_accept_invitation')}:
\n
......
......@@ -30,7 +30,7 @@ class Services::Facebook < Service
:invitation_identifier => data_h.keys})
invitation_objects.each do |inv|
data_h[inv.recipient.invitation_identifier][:invitation] = true
data_h[inv.recipient.invitation_identifier][:invitation_id] = inv.id
end
service_objects = Services::Facebook.where(:uid => data_h.keys).includes(:user => :person)
......
......@@ -28,8 +28,10 @@
:id => friend[:person].id},
:class => 'button',
:rel => 'facebox'
- elsif friend[:invitation]
- elsif friend[:invitation_id]
= t('invitations.new.already_invited')
%br
= link_to t('.resend'), service_inviter_path(:uid => uid, :provider => 'facebook', :invitation_id => friend[:invitation_id])
- else
= form_tag service_inviter_path do
= select_tag(:aspect_id, options_from_collection_for_select(@all_aspects, 'id', 'name'))
......
......@@ -427,6 +427,8 @@ en:
inviter:
join_me_on_diaspora: "Join me on DIASPORA*"
click_link_to_accept_invitation: "Click this link to accept your invitation"
finder:
resend: "resend"
notifier:
hello: "Hello %{name}!"
love: "love,"
......
......@@ -101,12 +101,6 @@ describe ServicesController do
@invite_params = {:provider => @service1.provider, :uid => @uid, :aspect_id => @user.aspects.first.id}
end
it 'creates an invitation' do
lambda {
put :inviter, @invite_params
}.should change(Invitation, :count).by(1)
end
it 'sets the subject' do
put :inviter, @invite_params
assigns[:subject].should_not be_nil
......@@ -122,6 +116,20 @@ describe ServicesController do
response.location.should match(/https:\/\/www\.facebook\.com\/\?compose=1&id=.*&subject=.*&message=.*&sk=messages/)
end
it 'creates an invitation' do
lambda {
put :inviter, @invite_params
}.should change(Invitation, :count).by(1)
end
it 'does not create a duplicate invitation' do
inv = Invitation.create!(:sender_id => @user.id, :recipient_id => eve.id, :aspect_id => @user.aspects.first.id)
@invite_params[:invitation_id] = inv.id
lambda {
put :inviter, @invite_params
}.should_not change(Invitation, :count)
end
end
end
......@@ -82,14 +82,14 @@ JSON
end
it 'contains an invitation if invited' do
@inv = Invitation.create(:sender => @user, :recipient => @user2, :aspect => @user.aspects.first)
@service.finder.values.first[:invitation].should be_true
@service.finder.values.first[:invitation_id].should == @inv.id
end
it 'does not find the user with a wrong identifier' do
@user2.invitation_identifier = 'dsaofhnadsoifnsdanf'
@user2.save
@inv = Invitation.create(:sender => @user, :recipient => @user2, :aspect => @user.aspects.first)
@service.finder.values.first[:invitation].should be_nil
@service.finder.values.first[:invitation_id].should be_nil
end
end
end
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment