Commit ac0943b0e0f500a734795676b196d5bde79f0da2
1 parent
481256d4
Exists in
master
and in
28 other branches
Added tests for subject of emails sent
(ActionItem1871)
Showing
9 changed files
with
54 additions
and
27 deletions
Show diff stats
app/models/email_activation.rb
@@ -27,10 +27,6 @@ class EmailActivation < Task | @@ -27,10 +27,6 @@ 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 | - | ||
34 | def perform | 30 | def perform |
35 | person.user.enable_email! | 31 | person.user.enable_email! |
36 | end | 32 | end |
app/models/task_mailer.rb
@@ -32,7 +32,7 @@ class TaskMailer < ActionMailer::Base | @@ -32,7 +32,7 @@ class TaskMailer < ActionMailer::Base | ||
32 | recipients task.friend_email | 32 | recipients task.friend_email |
33 | 33 | ||
34 | from self.class.generate_from(task) | 34 | from self.class.generate_from(task) |
35 | - subject '[%s] %s' % [ task.requestor.environment.name, task.information ] | 35 | + subject '[%s] %s' % [ task.requestor.environment.name, task.target_notification_description ] |
36 | body :message => msg | 36 | body :message => msg |
37 | end | 37 | end |
38 | 38 |
test/unit/approve_article_test.rb
@@ -362,6 +362,14 @@ class ApproveArticleTest < ActiveSupport::TestCase | @@ -362,6 +362,14 @@ class ApproveArticleTest < ActiveSupport::TestCase | ||
362 | assert_match(/#{task.requestor.name} wants to publish the article: #{article.name}/, email.subject) | 362 | assert_match(/#{task.requestor.name} wants to publish the article: #{article.name}/, email.subject) |
363 | end | 363 | end |
364 | 364 | ||
365 | + should 'deliver target finished message' do | ||
366 | + task = ApproveArticle.new(:article => article, :target => community, :requestor => profile) | ||
367 | + | ||
368 | + email = TaskMailer.deliver_task_finished(task) | ||
369 | + | ||
370 | + assert_match(/#{task.requestor.name} wants to publish the article: #{article.name}/, email.subject) | ||
371 | + end | ||
372 | + | ||
365 | should 'approve an event' do | 373 | should 'approve an event' do |
366 | event = fast_create(Event, :profile_id => profile.id, :name => 'Event test', :slug => 'event-test', :abstract => 'Lead of article', :body => 'This is my event') | 374 | event = fast_create(Event, :profile_id => profile.id, :name => 'Event test', :slug => 'event-test', :abstract => 'Lead of article', :body => 'This is my event') |
367 | task = ApproveArticle.create!(:name => 'Event test', :article => event, :target => community, :requestor => profile) | 375 | task = ApproveArticle.create!(:name => 'Event test', :article => event, :target => community, :requestor => profile) |
test/unit/change_password_test.rb
@@ -133,18 +133,20 @@ class ChangePasswordTest < Test::Unit::TestCase | @@ -133,18 +133,20 @@ class ChangePasswordTest < Test::Unit::TestCase | ||
133 | end | 133 | end |
134 | 134 | ||
135 | should 'have target notification description' do | 135 | should 'have target notification description' do |
136 | - person = create_user('testuser', :password => 'test', :password_confirmation => 'test', :email => 'test@example.com').person | 136 | + person = fast_create(Person, :identifier => 'testuser') |
137 | 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 | 138 | + change = ChangePassword.create(:login => 'testuser', :email => 'test@example.com', :environment_id => Environment.default.id) |
146 | 139 | ||
147 | assert_match(/#{change.requestor.name} wants to change its password/, change.target_notification_description) | 140 | assert_match(/#{change.requestor.name} wants to change its password/, change.target_notification_description) |
148 | end | 141 | end |
149 | 142 | ||
143 | + should 'deliver task created message' do | ||
144 | + person = fast_create(Person, :identifier => 'testuser') | ||
145 | + | ||
146 | + task = ChangePassword.create(:login => 'testuser', :email => 'test@example.com', :environment_id => Environment.default.id) | ||
147 | + | ||
148 | + email = TaskMailer.deliver_task_created(task) | ||
149 | + assert_match(/#{task.requestor.name} wants to change its password/, email.subject) | ||
150 | + end | ||
151 | + | ||
150 | end | 152 | end |
test/unit/email_activation_test.rb
@@ -49,11 +49,13 @@ class EmailActivationTest < Test::Unit::TestCase | @@ -49,11 +49,13 @@ 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) | 52 | + should 'deliver activation email notification' do |
53 | + user = create_user('testuser', :environment_id => Environment.default.id) | ||
54 | + | ||
55 | + task = EmailActivation.new(:requestor => user.person, :target => Environment.default) | ||
55 | 56 | ||
56 | - assert_match(/#{task.requestor.name} wants to activate the following email: #{task.subject}/, task.target_notification_description) | 57 | + email = User::Mailer.deliver_activation_email_notify(user) |
58 | + assert_match(/Welcome to #{task.requestor.environment.name} mail!/, email.subject) | ||
57 | end | 59 | end |
58 | 60 | ||
59 | end | 61 | end |
test/unit/enterprise_activation_test.rb
@@ -65,15 +65,11 @@ class EnterpriseActivationTest < ActiveSupport::TestCase | @@ -65,15 +65,11 @@ class EnterpriseActivationTest < ActiveSupport::TestCase | ||
65 | end | 65 | end |
66 | 66 | ||
67 | should 'have target notification description' do | 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 | 68 | + ent = fast_create(Enterprise, :enabled => false) |
69 | + task = EnterpriseActivation.create!(:enterprise => ent, :requestor => profiles(:ze)) | ||
73 | 70 | ||
74 | - assert_match(/#{t.requestor.name} wants to activate enterprise #{ent.name}/, t.target_notification_description) | 71 | + assert_match(/#{task.requestor.name} wants to activate enterprise #{ent.name}/, task.target_notification_description) |
75 | end | 72 | end |
76 | 73 | ||
77 | - | ||
78 | end | 74 | end |
79 | 75 |
test/unit/invite_friend_test.rb
@@ -121,11 +121,21 @@ class InviteFriendTest < ActiveSupport::TestCase | @@ -121,11 +121,21 @@ class InviteFriendTest < ActiveSupport::TestCase | ||
121 | end | 121 | end |
122 | 122 | ||
123 | should 'have target notification description' do | 123 | should 'have target notification description' do |
124 | - p = create_user('testuser1').person | 124 | + person = create_user('testuser1').person |
125 | 125 | ||
126 | - task = InviteFriend.create!(:person => p, :friend_email => 'test@test.com', :message => '<url>') | 126 | + task = InviteFriend.create!(:person => person, :friend_email => 'test@test.com', :message => '<url>') |
127 | 127 | ||
128 | assert_match(/#{task.requestor.name} wants to be your friend./, task.target_notification_description) | 128 | assert_match(/#{task.requestor.name} wants to be your friend./, task.target_notification_description) |
129 | end | 129 | end |
130 | 130 | ||
131 | + should 'deliver invitation notification' do | ||
132 | + person = create_user('testuser1').person | ||
133 | + | ||
134 | + task = InviteFriend.create!(:person => person, :friend_email => 'test@test.com', :message => '<url>') | ||
135 | + | ||
136 | + email = TaskMailer.deliver_invitation_notification(task) | ||
137 | + | ||
138 | + assert_match(/#{task.requestor.name} wants to be your friend./, email.subject) | ||
139 | + end | ||
140 | + | ||
131 | end | 141 | end |
test/unit/invite_member_test.rb
@@ -104,5 +104,16 @@ class InviteMemberTest < ActiveSupport::TestCase | @@ -104,5 +104,16 @@ class InviteMemberTest < ActiveSupport::TestCase | ||
104 | assert_match(/#{task.requestor.name} invited you to join #{community.name}/, task.target_notification_description) | 104 | assert_match(/#{task.requestor.name} invited you to join #{community.name}/, task.target_notification_description) |
105 | end | 105 | end |
106 | 106 | ||
107 | + should 'deliver invitation notification' do | ||
108 | + person = create_user('testuser1').person | ||
109 | + community = fast_create(Community) | ||
110 | + | ||
111 | + task = InviteMember.create!(:person => person, :friend_email => 'test@test.com', :message => '<url>', :community_id => community.id) | ||
112 | + | ||
113 | + email = TaskMailer.deliver_invitation_notification(task) | ||
114 | + | ||
115 | + assert_match(/#{task.requestor.name} invited you to join #{community.name}/, email.subject) | ||
116 | + end | ||
117 | + | ||
107 | end | 118 | end |
108 | 119 |
test/unit/task_mailer_test.rb
@@ -129,6 +129,8 @@ class TaskMailerTest < Test::Unit::TestCase | @@ -129,6 +129,8 @@ class TaskMailerTest < Test::Unit::TestCase | ||
129 | 129 | ||
130 | mail = TaskMailer.create_invitation_notification(task) | 130 | mail = TaskMailer.create_invitation_notification(task) |
131 | 131 | ||
132 | + assert_match(/#{task.target_notification_description}/, mail.subject) | ||
133 | + | ||
132 | assert_equal "Hello friend name, my name invite you, please follow this link: http://example.com/account/signup?invitation_code=123456", mail.body | 134 | assert_equal "Hello friend name, my name invite you, please follow this link: http://example.com/account/signup?invitation_code=123456", mail.body |
133 | 135 | ||
134 | TaskMailer.deliver(mail) | 136 | TaskMailer.deliver(mail) |