[Git][noosfero/noosfero][master] 3 commits: Show email of requestor in AddMember task

Rodrigo Souto gitlab at gitlab.com
Thu Oct 8 11:51:27 BRT 2015


Rodrigo Souto pushed to branch master at Noosfero / noosfero


Commits:
a4d115e7 by Luciano Prestes Cavalcanti at 2015-10-07T19:34:08Z
Show email of requestor in AddMember task

Signed-off-by: Luciano Prestes Cavalcanti <lucianopcbr at gmail.com>
Signed-off-by: Simiao Carvalho <simiaosimis at gmail.com>
Signed-off-by: Thiago Ribeiro <thiagitosouza at gmail.com>

- - - - -
8ac3abc1 by Luciano Prestes Cavalcanti at 2015-10-08T16:33:34Z
Fix and add tests for show requestor email on AddMember task

- - - - -
9c9f0fbc by Rodrigo Souto at 2015-10-08T14:50:41Z
Merge branch 'show_email_in_task' into 'master'

Show email of requestor in AddMember task

Add user email on the screen to process the request to enter on the community.

softwarepublico issue: https://softwarepublico.gov.br/gitlab/softwarepublico/softwarepublico/issues/238

See merge request !696
- - - - -


2 changed files:

- app/models/add_member.rb
- test/unit/add_member_test.rb


Changes:

=====================================
app/models/add_member.rb
=====================================
--- 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


=====================================
test/unit/add_member_test.rb
=====================================
--- a/test/unit/add_member_test.rb
+++ b/test/unit/add_member_test.rb
@@ -121,4 +121,21 @@ class AddMemberTest < ActiveSupport::TestCase
     assert_match(/#{task.requestor.name} wants to be a member of '#{community.name}'/, email.subject)
   end
 
+  should 'notification description with requestor email if requestor email is public' 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.email}\)/, task.target_notification_description)
+  end
+
+  should 'notification description without requestor email if requestor email is not public' do
+    new_person = create_user('testuser').person
+    new_person.update_attributes!({:fields_privacy => {:email => '0'}})
+
+    task = AddMember.new(:person => new_person, :organization => community)
+
+    assert_not_match(/\(#{task.requestor.email}\)/, task.target_notification_description)
+  end
 end



View it on GitLab: https://gitlab.com/noosfero/noosfero/compare/5e8e25e98cf06dc6413596aebb6869559de93b1a...9c9f0fbcf6f586fb71a768fd0706331fb15f228f
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20151008/f330a554/attachment.html>


More information about the Noosfero-dev mailing list