Commit c8236d24a84f33dc39967b6a9c8c0c90d728fd21
1 parent
216fb6a4
Exists in
master
and in
27 other branches
Send notification message to invited user
Showing
4 changed files
with
36 additions
and
7 deletions
Show diff stats
app/controllers/public/invite_controller.rb
@@ -58,9 +58,8 @@ class InviteController < PublicController | @@ -58,9 +58,8 @@ class InviteController < PublicController | ||
58 | 58 | ||
59 | def invite_registered_friend | 59 | def invite_registered_friend |
60 | contacts_to_invite = params['q'].split(',') | 60 | contacts_to_invite = params['q'].split(',') |
61 | - mail_template = params[:mail_template] || environment.invitation_mail_template(profile) | ||
62 | if !contacts_to_invite.empty? | 61 | if !contacts_to_invite.empty? |
63 | - Delayed::Job.enqueue InvitationJob.new(current_user.person.id, contacts_to_invite, mail_template, profile.id, nil, locale) | 62 | + Delayed::Job.enqueue InvitationJob.new(current_user.person.id, contacts_to_invite, '', profile.id, nil, locale) |
64 | session[:notice] = _('Your invitations are being sent.') | 63 | session[:notice] = _('Your invitations are being sent.') |
65 | if profile.person? | 64 | if profile.person? |
66 | redirect_to :controller => 'profile', :action => 'friends' | 65 | redirect_to :controller => 'profile', :action => 'friends' |
app/models/invite_member.rb
@@ -39,6 +39,14 @@ class InviteMember < Invitation | @@ -39,6 +39,14 @@ class InviteMember < Invitation | ||
39 | _('%{requestor} invited you to join %{community}.') % {:requestor => requestor.name, :community => community.name} | 39 | _('%{requestor} invited you to join %{community}.') % {:requestor => requestor.name, :community => community.name} |
40 | end | 40 | end |
41 | 41 | ||
42 | + def target_notification_message | ||
43 | + if friend | ||
44 | + _('%{requestor} is inviting you to join "%{community}" on %{system}.') % { :system => target.environment.name, :requestor => requestor.name, :community => community.name } | ||
45 | + else | ||
46 | + super | ||
47 | + end | ||
48 | + end | ||
49 | + | ||
42 | def expanded_message | 50 | def expanded_message |
43 | super.gsub /<community>/, community.name | 51 | super.gsub /<community>/, community.name |
44 | end | 52 | end |
app/views/invite/invite_friends.rhtml
@@ -13,8 +13,6 @@ | @@ -13,8 +13,6 @@ | ||
13 | { :hint_text => _('Type in your friend\'s ') + search_friend_fields, | 13 | { :hint_text => _('Type in your friend\'s ') + search_friend_fields, |
14 | :focus => false }) %> | 14 | :focus => false }) %> |
15 | 15 | ||
16 | - <%= render :partial => 'invite/personalize_invitation_mail', :locals => {:mail_template => @mail_template } %> | ||
17 | - | ||
18 | <% button_bar do %> | 16 | <% button_bar do %> |
19 | <%= submit_button('save', _('Invite'))%> | 17 | <%= submit_button('save', _('Invite'))%> |
20 | <%= button('cancel', _('Cancel'), profile.url)%> | 18 | <%= button('cancel', _('Cancel'), profile.url)%> |
test/unit/invite_member_test.rb
@@ -76,11 +76,11 @@ class InviteMemberTest < ActiveSupport::TestCase | @@ -76,11 +76,11 @@ class InviteMemberTest < ActiveSupport::TestCase | ||
76 | task = InviteMember.create!(:person => p1, :friend_email => 'test@test.com', :message => '<url>', :community_id => fast_create(Community).id) | 76 | task = InviteMember.create!(:person => p1, :friend_email => 'test@test.com', :message => '<url>', :community_id => fast_create(Community).id) |
77 | end | 77 | end |
78 | 78 | ||
79 | - should 'not send e-mails to friend if target given (person being invited)' do | 79 | + should 'send e-mails notification to friend if target given (person being invited)' do |
80 | p1 = create_user('testuser1').person | 80 | p1 = create_user('testuser1').person |
81 | p2 = create_user('testuser2').person | 81 | p2 = create_user('testuser2').person |
82 | 82 | ||
83 | - TaskMailer.expects(:deliver_invitation_notification).never | 83 | + TaskMailer.expects(:deliver_target_notification).once |
84 | 84 | ||
85 | task = InviteMember.create!(:person => p1, :friend => p2, :community_id => fast_create(Community).id) | 85 | task = InviteMember.create!(:person => p1, :friend => p2, :community_id => fast_create(Community).id) |
86 | end | 86 | end |
@@ -115,5 +115,29 @@ class InviteMemberTest < ActiveSupport::TestCase | @@ -115,5 +115,29 @@ class InviteMemberTest < ActiveSupport::TestCase | ||
115 | assert_match(/#{task.requestor.name} invited you to join #{community.name}/, email.subject) | 115 | assert_match(/#{task.requestor.name} invited you to join #{community.name}/, email.subject) |
116 | end | 116 | end |
117 | 117 | ||
118 | -end | 118 | + should 'have target notification message only if target given (person being invited)' do |
119 | + p1 = create_user('testuser1').person | ||
120 | + p2 = create_user('testuser2').person | ||
121 | + | ||
122 | + task = InviteMember.create!(:person => p1, :friend => p2, :community_id => fast_create(Community).id) | ||
123 | + assert_nothing_raised NotImplementedError do | ||
124 | + task.target_notification_message | ||
125 | + end | ||
126 | + | ||
127 | + task = InviteMember.create!(:person => p1, :friend_email => 'test@test.com', :message => '<url>', :community_id => fast_create(Community).id) | ||
128 | + assert_raise NotImplementedError do | ||
129 | + task.target_notification_message | ||
130 | + end | ||
131 | + end | ||
119 | 132 | ||
133 | + should 'deliver target notification message if target given (person being invited)' do | ||
134 | + p1 = create_user('testuser1').person | ||
135 | + p2 = create_user('testuser2').person | ||
136 | + | ||
137 | + task = InviteMember.create!(:person => p1, :friend => p2, :community_id => fast_create(Community).id) | ||
138 | + | ||
139 | + email = TaskMailer.deliver_target_notification(task, task.target_notification_message) | ||
140 | + assert_match(/#{task.requestor.name} invited you to join #{task.community.name}/, email.subject) | ||
141 | + end | ||
142 | + | ||
143 | +end |