Commit 481256d48763676d08b68285e4d883cb4057fef9
Committed by
Daniela Feitosa
1 parent
0e54aafd
Exists in
master
and in
29 other branches
Method target_notification_description for tasks
(ActionItem1871)
Showing
12 changed files
with
74 additions
and
4 deletions
Show diff stats
app/models/change_password.rb
@@ -78,6 +78,10 @@ class ChangePassword < Task | @@ -78,6 +78,10 @@ class ChangePassword < Task | ||
78 | user.force_change_password!(self.password, self.password_confirmation) | 78 | user.force_change_password!(self.password, self.password_confirmation) |
79 | end | 79 | end |
80 | 80 | ||
81 | + def target_notification_description | ||
82 | + _('%{requestor} wants to change its password.') % {:requestor => requestor.name} | ||
83 | + end | ||
84 | + | ||
81 | # overriding messages | 85 | # overriding messages |
82 | 86 | ||
83 | def task_cancelled_message | 87 | def task_cancelled_message |
app/models/email_activation.rb
@@ -27,6 +27,10 @@ class EmailActivation < Task | @@ -27,6 +27,10 @@ class EmailActivation < Task | ||
27 | {:type => :profile_image, :profile => requestor, :url => requestor.url} | 27 | {:type => :profile_image, :profile => requestor, :url => requestor.url} |
28 | end | 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 | def perform | 34 | def perform |
31 | person.user.enable_email! | 35 | person.user.enable_email! |
32 | end | 36 | end |
app/models/enterprise_activation.rb
@@ -36,4 +36,8 @@ class EnterpriseActivation < Task | @@ -36,4 +36,8 @@ class EnterpriseActivation < Task | ||
36 | {:type => :profile_image, :profile => requestor, :url => requestor.url} | 36 | {:type => :profile_image, :profile => requestor, :url => requestor.url} |
37 | end | 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 | end | 43 | end |
app/models/invite_friend.rb
@@ -23,6 +23,10 @@ class InviteFriend < Invitation | @@ -23,6 +23,10 @@ class InviteFriend < Invitation | ||
23 | {:type => :profile_image, :profile => requestor, :url => requestor.url} | 23 | {:type => :profile_image, :profile => requestor, :url => requestor.url} |
24 | end | 24 | end |
25 | 25 | ||
26 | + def target_notification_description | ||
27 | + _('%{requestor} wants to be your friend.') % {:requestor => requestor.name} | ||
28 | + end | ||
29 | + | ||
26 | def permission | 30 | def permission |
27 | :manage_friends | 31 | :manage_friends |
28 | end | 32 | end |
app/models/invite_member.rb
@@ -35,6 +35,10 @@ class InviteMember < Invitation | @@ -35,6 +35,10 @@ class InviteMember < Invitation | ||
35 | {:type => :profile_image, :profile => community, :url => community.url} | 35 | {:type => :profile_image, :profile => community, :url => community.url} |
36 | end | 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 | def expanded_message | 42 | def expanded_message |
39 | super.gsub /<community>/, community.name | 43 | super.gsub /<community>/, community.name |
40 | end | 44 | end |
app/models/task_mailer.rb
@@ -52,7 +52,7 @@ class TaskMailer < ActionMailer::Base | @@ -52,7 +52,7 @@ class TaskMailer < ActionMailer::Base | ||
52 | 52 | ||
53 | recipients task.requestor.notification_emails | 53 | recipients task.requestor.notification_emails |
54 | from self.class.generate_from(task) | 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 | body :requestor => task.requestor.name, | 56 | body :requestor => task.requestor.name, |
57 | :message => text, | 57 | :message => text, |
58 | :environment => task.requestor.environment.name, | 58 | :environment => task.requestor.environment.name, |
test/unit/change_password_test.rb
@@ -132,4 +132,19 @@ class ChangePasswordTest < Test::Unit::TestCase | @@ -132,4 +132,19 @@ class ChangePasswordTest < Test::Unit::TestCase | ||
132 | assert_equal c2.requestor, p2 | 132 | assert_equal c2.requestor, p2 |
133 | end | 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 | end | 150 | end |
test/unit/email_activation_test.rb
@@ -49,4 +49,11 @@ class EmailActivationTest < Test::Unit::TestCase | @@ -49,4 +49,11 @@ class EmailActivationTest < Test::Unit::TestCase | ||
49 | assert !anothertask.save | 49 | assert !anothertask.save |
50 | end | 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 | end | 59 | end |
test/unit/enterprise_activation_test.rb
@@ -64,5 +64,16 @@ class EnterpriseActivationTest < ActiveSupport::TestCase | @@ -64,5 +64,16 @@ class EnterpriseActivationTest < ActiveSupport::TestCase | ||
64 | t.finish | 64 | t.finish |
65 | end | 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 | end | 78 | end |
68 | 79 |
test/unit/invite_friend_test.rb
@@ -120,4 +120,12 @@ class InviteFriendTest < ActiveSupport::TestCase | @@ -120,4 +120,12 @@ class InviteFriendTest < ActiveSupport::TestCase | ||
120 | assert !task2.save | 120 | assert !task2.save |
121 | end | 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 | end | 131 | end |
test/unit/invite_member_test.rb
@@ -95,5 +95,14 @@ class InviteMemberTest < ActiveSupport::TestCase | @@ -95,5 +95,14 @@ class InviteMemberTest < ActiveSupport::TestCase | ||
95 | assert !task2.save | 95 | assert !task2.save |
96 | end | 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 | end | 107 | end |
99 | 108 |
test/unit/task_mailer_test.rb
@@ -17,7 +17,7 @@ class TaskMailerTest < Test::Unit::TestCase | @@ -17,7 +17,7 @@ class TaskMailerTest < Test::Unit::TestCase | ||
17 | 17 | ||
18 | task = Task.new | 18 | task = Task.new |
19 | task.expects(:task_finished_message).returns('the message') | 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 | requestor = mock() | 22 | requestor = mock() |
23 | requestor.expects(:notification_emails).returns(['requestor@example.com']) | 23 | requestor.expects(:notification_emails).returns(['requestor@example.com']) |
@@ -40,7 +40,7 @@ class TaskMailerTest < Test::Unit::TestCase | @@ -40,7 +40,7 @@ class TaskMailerTest < Test::Unit::TestCase | ||
40 | 40 | ||
41 | task = Task.new | 41 | task = Task.new |
42 | task.expects(:task_cancelled_message).returns('the message') | 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 | requestor = mock() | 45 | requestor = mock() |
46 | requestor.expects(:notification_emails).returns(['requestor@example.com']) | 46 | requestor.expects(:notification_emails).returns(['requestor@example.com']) |
@@ -64,7 +64,7 @@ class TaskMailerTest < Test::Unit::TestCase | @@ -64,7 +64,7 @@ class TaskMailerTest < Test::Unit::TestCase | ||
64 | task = Task.new | 64 | task = Task.new |
65 | 65 | ||
66 | task.expects(:task_created_message).returns('the message') | 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 | requestor = mock() | 69 | requestor = mock() |
70 | requestor.expects(:notification_emails).returns(['requestor@example.com']) | 70 | requestor.expects(:notification_emails).returns(['requestor@example.com']) |