Commit 481256d48763676d08b68285e4d883cb4057fef9

Authored by Keilla Menezes
Committed by Daniela Feitosa
1 parent 0e54aafd

Method target_notification_description for tasks

(ActionItem1871)
app/models/change_password.rb
... ... @@ -78,6 +78,10 @@ class ChangePassword < Task
78 78 user.force_change_password!(self.password, self.password_confirmation)
79 79 end
80 80  
  81 + def target_notification_description
  82 + _('%{requestor} wants to change its password.') % {:requestor => requestor.name}
  83 + end
  84 +
81 85 # overriding messages
82 86  
83 87 def task_cancelled_message
... ...
app/models/email_activation.rb
... ... @@ -27,6 +27,10 @@ class EmailActivation < Task
27 27 {:type => :profile_image, :profile => requestor, :url => requestor.url}
28 28 end
29 29  
  30 + def target_notification_description
  31 + _("%{requestor} wants to activate the following email: %{subject}.") % {:requestor => requestor.name, :subject => subject }
  32 + end
  33 +
30 34 def perform
31 35 person.user.enable_email!
32 36 end
... ...
app/models/enterprise_activation.rb
... ... @@ -36,4 +36,8 @@ class EnterpriseActivation < Task
36 36 {:type => :profile_image, :profile => requestor, :url => requestor.url}
37 37 end
38 38  
  39 + def target_notification_description
  40 + _('%{requestor} wants to activate enterprise %{enterprise}.') % {:requestor => requestor.name, :enterprise => enterprise.name}
  41 + end
  42 +
39 43 end
... ...
app/models/invite_friend.rb
... ... @@ -23,6 +23,10 @@ class InviteFriend < Invitation
23 23 {:type => :profile_image, :profile => requestor, :url => requestor.url}
24 24 end
25 25  
  26 + def target_notification_description
  27 + _('%{requestor} wants to be your friend.') % {:requestor => requestor.name}
  28 + end
  29 +
26 30 def permission
27 31 :manage_friends
28 32 end
... ...
app/models/invite_member.rb
... ... @@ -35,6 +35,10 @@ class InviteMember < Invitation
35 35 {:type => :profile_image, :profile => community, :url => community.url}
36 36 end
37 37  
  38 + def target_notification_description
  39 + _('%{requestor} invited you to join %{community}.') % {:requestor => requestor.name, :community => community.name}
  40 + end
  41 +
38 42 def expanded_message
39 43 super.gsub /<community>/, community.name
40 44 end
... ...
app/models/task_mailer.rb
... ... @@ -52,7 +52,7 @@ class TaskMailer &lt; ActionMailer::Base
52 52  
53 53 recipients task.requestor.notification_emails
54 54 from self.class.generate_from(task)
55   - subject '[%s] %s' % [task.requestor.environment.name, task.information]
  55 + subject '[%s] %s' % [task.requestor.environment.name, task.target_notification_description]
56 56 body :requestor => task.requestor.name,
57 57 :message => text,
58 58 :environment => task.requestor.environment.name,
... ...
test/unit/change_password_test.rb
... ... @@ -132,4 +132,19 @@ class ChangePasswordTest &lt; Test::Unit::TestCase
132 132 assert_equal c2.requestor, p2
133 133 end
134 134  
  135 + should 'have target notification description' do
  136 + person = create_user('testuser', :password => 'test', :password_confirmation => 'test', :email => 'test@example.com').person
  137 +
  138 + change = ChangePassword.new
  139 + change.login = 'testuser'
  140 + change.email = 'test@example.com'
  141 + change.environment_id = Environment.default.id
  142 + change.save!
  143 + change.password = 'newpass'
  144 + change.password_confirmation = 'newpass'
  145 + change.finish
  146 +
  147 + assert_match(/#{change.requestor.name} wants to change its password/, change.target_notification_description)
  148 + end
  149 +
135 150 end
... ...
test/unit/email_activation_test.rb
... ... @@ -49,4 +49,11 @@ class EmailActivationTest &lt; Test::Unit::TestCase
49 49 assert !anothertask.save
50 50 end
51 51  
  52 + should 'have target notification description' do
  53 + ze = create_user('zezinho', :environment_id => Environment.default.id)
  54 + task = EmailActivation.new(:requestor => ze.person, :target => Environment.default)
  55 +
  56 + assert_match(/#{task.requestor.name} wants to activate the following email: #{task.subject}/, task.target_notification_description)
  57 + end
  58 +
52 59 end
... ...
test/unit/enterprise_activation_test.rb
... ... @@ -64,5 +64,16 @@ class EnterpriseActivationTest &lt; ActiveSupport::TestCase
64 64 t.finish
65 65 end
66 66  
  67 + should 'have target notification description' do
  68 + ent = Enterprise.create!(:name => 'my enterprise', :identifier => 'myent', :enabled => false)
  69 + t = EnterpriseActivation.create!(:enterprise => ent)
  70 +
  71 + person = profiles(:ze)
  72 + t.requestor = person
  73 +
  74 + assert_match(/#{t.requestor.name} wants to activate enterprise #{ent.name}/, t.target_notification_description)
  75 + end
  76 +
  77 +
67 78 end
68 79  
... ...
test/unit/invite_friend_test.rb
... ... @@ -120,4 +120,12 @@ class InviteFriendTest &lt; ActiveSupport::TestCase
120 120 assert !task2.save
121 121 end
122 122  
  123 + should 'have target notification description' do
  124 + p = create_user('testuser1').person
  125 +
  126 + task = InviteFriend.create!(:person => p, :friend_email => 'test@test.com', :message => '<url>')
  127 +
  128 + assert_match(/#{task.requestor.name} wants to be your friend./, task.target_notification_description)
  129 + end
  130 +
123 131 end
... ...
test/unit/invite_member_test.rb
... ... @@ -95,5 +95,14 @@ class InviteMemberTest &lt; ActiveSupport::TestCase
95 95 assert !task2.save
96 96 end
97 97  
  98 + should 'have target notification description' do
  99 + p = create_user('testuser1').person
  100 + community = fast_create(Community)
  101 +
  102 + task = InviteMember.create!(:person => p, :friend_email => 'test@test.com', :message => '<url>', :community_id => community.id)
  103 +
  104 + assert_match(/#{task.requestor.name} invited you to join #{community.name}/, task.target_notification_description)
  105 + end
  106 +
98 107 end
99 108  
... ...
test/unit/task_mailer_test.rb
... ... @@ -17,7 +17,7 @@ class TaskMailerTest &lt; Test::Unit::TestCase
17 17  
18 18 task = Task.new
19 19 task.expects(:task_finished_message).returns('the message')
20   - task.expects(:information).returns('the task')
  20 + task.expects(:target_notification_description).returns('the task')
21 21  
22 22 requestor = mock()
23 23 requestor.expects(:notification_emails).returns(['requestor@example.com'])
... ... @@ -40,7 +40,7 @@ class TaskMailerTest &lt; Test::Unit::TestCase
40 40  
41 41 task = Task.new
42 42 task.expects(:task_cancelled_message).returns('the message')
43   - task.expects(:information).returns('the task')
  43 + task.expects(:target_notification_description).returns('the task')
44 44  
45 45 requestor = mock()
46 46 requestor.expects(:notification_emails).returns(['requestor@example.com'])
... ... @@ -64,7 +64,7 @@ class TaskMailerTest &lt; Test::Unit::TestCase
64 64 task = Task.new
65 65  
66 66 task.expects(:task_created_message).returns('the message')
67   - task.expects(:information).returns('the task')
  67 + task.expects(:target_notification_description).returns('the task')
68 68  
69 69 requestor = mock()
70 70 requestor.expects(:notification_emails).returns(['requestor@example.com'])
... ...