##// END OF EJS Templates
Adds an helper to get the body of an email in tests....
Jean-Philippe Lang -
r8972:df89c24e37af
parent child
Show More
@@ -164,20 +164,24 class ActiveSupport::TestCase
164
164
165 def assert_mail_body_match(expected, mail)
165 def assert_mail_body_match(expected, mail)
166 if expected.is_a?(String)
166 if expected.is_a?(String)
167 assert_include expected, mail.body
167 assert_include expected, mail_body(mail)
168 else
168 else
169 assert_match expected, mail.body
169 assert_match expected, mail_body(mail)
170 end
170 end
171 end
171 end
172
172
173 def assert_mail_body_no_match(expected, mail)
173 def assert_mail_body_no_match(expected, mail)
174 if expected.is_a?(String)
174 if expected.is_a?(String)
175 assert_not_include expected, mail.body
175 assert_not_include expected, mail_body(mail)
176 else
176 else
177 assert_no_match expected, mail.body
177 assert_no_match expected, mail_body(mail)
178 end
178 end
179 end
179 end
180
180
181 def mail_body(mail)
182 mail.body
183 end
184
181 # Shoulda macros
185 # Shoulda macros
182 def self.should_render_404
186 def self.should_render_404
183 should_respond_with :not_found
187 should_respond_with :not_found
@@ -158,7 +158,7 class Redmine::Hook::ManagerTest < ActiveSupport::TestCase
158 Mailer.deliver_issue_add(issue)
158 Mailer.deliver_issue_add(issue)
159 mail2 = ActionMailer::Base.deliveries.last
159 mail2 = ActionMailer::Base.deliveries.last
160
160
161 assert_equal mail.body, mail2.body
161 assert_equal mail_body(mail), mail_body(mail2)
162 end
162 end
163
163
164 def hook_helper
164 def hook_helper
@@ -272,8 +272,8 class MailHandlerTest < ActiveSupport::TestCase
272 email = ActionMailer::Base.deliveries.first
272 email = ActionMailer::Base.deliveries.first
273 assert_not_nil email
273 assert_not_nil email
274 assert email.subject.include?('account activation')
274 assert email.subject.include?('account activation')
275 login = email.body.match(/\* Login: (.*)$/)[1]
275 login = mail_body(email).match(/\* Login: (.*)$/)[1]
276 password = email.body.match(/\* Password: (.*)$/)[1]
276 password = mail_body(email).match(/\* Password: (.*)$/)[1]
277 assert_equal issue.author, User.try_to_login(login, password)
277 assert_equal issue.author, User.try_to_login(login, password)
278 end
278 end
279 end
279 end
General Comments 0
You need to be logged in to leave comments. Login now