Commit a4d115e79924df9a00ac9dfa57d57c06b72f3a24
1 parent
92476194
Exists in
master
and in
21 other branches
Show email of requestor in AddMember task
Signed-off-by: Luciano Prestes Cavalcanti <lucianopcbr@gmail.com> Signed-off-by: Simiao Carvalho <simiaosimis@gmail.com> Signed-off-by: Thiago Ribeiro <thiagitosouza@gmail.com>
Showing
2 changed files
with
15 additions
and
3 deletions
Show diff stats
app/models/add_member.rb
| ... | ... | @@ -29,8 +29,10 @@ class AddMember < Task |
| 29 | 29 | end |
| 30 | 30 | |
| 31 | 31 | def information |
| 32 | - {:message => _("%{requestor} wants to be a member of '%{organization}'."), | |
| 33 | - variables: {requestor: requestor.name, organization: organization.name}} | |
| 32 | + requestor_email = " (#{requestor.email})" if requestor.may_display_field_to?("email") | |
| 33 | + | |
| 34 | + {:message => _("%{requestor}%{requestor_email} wants to be a member of '%{organization}'."), | |
| 35 | + variables: {requestor: requestor.name, requestor_email: requestor_email, organization: organization.name}} | |
| 34 | 36 | end |
| 35 | 37 | |
| 36 | 38 | def accept_details |
| ... | ... | @@ -46,7 +48,9 @@ class AddMember < Task |
| 46 | 48 | end |
| 47 | 49 | |
| 48 | 50 | def target_notification_description |
| 49 | - _("%{requestor} wants to be a member of '%{organization}'.") % {:requestor => requestor.name, :organization => organization.name} | |
| 51 | + requestor_email = " (#{requestor.email})" if requestor.may_display_field_to?("email") | |
| 52 | + | |
| 53 | + _("%{requestor}%{requestor_email} wants to be a member of '%{organization}'.") % {:requestor => requestor.name, :requestor_email => requestor_email, :organization => organization.name} | |
| 50 | 54 | end |
| 51 | 55 | |
| 52 | 56 | def target_notification_message | ... | ... |
test/unit/add_member_test.rb
| ... | ... | @@ -121,4 +121,12 @@ class AddMemberTest < ActiveSupport::TestCase |
| 121 | 121 | assert_match(/#{task.requestor.name} wants to be a member of '#{community.name}'/, email.subject) |
| 122 | 122 | end |
| 123 | 123 | |
| 124 | + should 'have target notification description with requestor email' do | |
| 125 | + new_person = create_user('testuser').person | |
| 126 | + new_person.update_attributes!({:fields_privacy => {:email => 'public'}}) | |
| 127 | + | |
| 128 | + task = AddMember.new(:person => new_person, :organization => community) | |
| 129 | + | |
| 130 | + assert_match(/#{task.requestor.name} \(#{task.requestor.email}\) wants to be a member of '#{community.name}'./, task.target_notification_description) | |
| 131 | + end | |
| 124 | 132 | end | ... | ... |