From 3c238164839ef31ce33be6cf7e78b438c23250d8 Mon Sep 17 00:00:00 2001 From: Luciano Prestes Cavalcanti Date: Mon, 5 Oct 2015 22:17:56 +0200 Subject: [PATCH] Show email of requestor in AddMember task --- app/models/add_member.rb | 10 +++++++--- test/unit/add_member_test.rb | 8 ++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/app/models/add_member.rb b/app/models/add_member.rb index 44fa62f..ca41275 100644 --- a/app/models/add_member.rb +++ b/app/models/add_member.rb @@ -29,8 +29,10 @@ class AddMember < Task end def information - {:message => _("%{requestor} wants to be a member of '%{organization}'."), - variables: {requestor: requestor.name, organization: organization.name}} + requestor_email = " (#{requestor.email})" if requestor.may_display_field_to?("email") + + {:message => _("%{requestor}%{requestor_email} wants to be a member of '%{organization}'."), + variables: {requestor: requestor.name, requestor_email: requestor_email, organization: organization.name}} end def accept_details @@ -46,7 +48,9 @@ class AddMember < Task end def target_notification_description - _("%{requestor} wants to be a member of '%{organization}'.") % {:requestor => requestor.name, :organization => organization.name} + requestor_email = " (#{requestor.email})" if requestor.may_display_field_to?("email") + + _("%{requestor}%{requestor_email} wants to be a member of '%{organization}'.") % {:requestor => requestor.name, :requestor_email => requestor_email, :organization => organization.name} end def target_notification_message diff --git a/test/unit/add_member_test.rb b/test/unit/add_member_test.rb index 8c0d51b..27e29ca 100644 --- a/test/unit/add_member_test.rb +++ b/test/unit/add_member_test.rb @@ -121,4 +121,12 @@ class AddMemberTest < ActiveSupport::TestCase assert_match(/#{task.requestor.name} wants to be a member of '#{community.name}'/, email.subject) end + should 'have target notification description with requestor email' do + new_person = create_user('testuser').person + new_person.update_attributes!({:fields_privacy => {:email => 'public'}}) + + task = AddMember.new(:person => new_person, :organization => community) + + assert_match(/#{task.requestor.name} \(#{task.requestor.email}\) wants to be a member of '#{community.name}'./, task.target_notification_description) + end end -- libgit2 0.21.2