summaryrefslogtreecommitdiffstats
path: root/test/unit/mailer_test.rb
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2016-02-05 07:33:24 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2016-02-05 07:33:24 +0000
commit5d70fce6ce4c481f058fc1b89d567c1389cb7e54 (patch)
treefe7c5a9602d73ef312b544783efb0ff645bc7f1d /test/unit/mailer_test.rb
parent40e6a74d4834f171bd8080dce39c587d84fb86da (diff)
downloadredmine-5d70fce6ce4c481f058fc1b89d567c1389cb7e54.tar.gz
redmine-5d70fce6ce4c481f058fc1b89d567c1389cb7e54.zip
Security notifications when password or email adress is changed (#21421).
Patch by Jan Schulz-Hofen. git-svn-id: http://svn.redmine.org/redmine/trunk@15145 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/unit/mailer_test.rb')
-rw-r--r--test/unit/mailer_test.rb45
1 files changed, 45 insertions, 0 deletions
diff --git a/test/unit/mailer_test.rb b/test/unit/mailer_test.rb
index 8de5bfe56..9ee179400 100644
--- a/test/unit/mailer_test.rb
+++ b/test/unit/mailer_test.rb
@@ -666,6 +666,51 @@ class MailerTest < ActiveSupport::TestCase
end
end
+ def test_security_notification
+ set_language_if_valid User.find(1).language
+ with_settings :emails_footer => "footer without link" do
+ User.current.remote_ip = '192.168.1.1'
+ assert Mailer.security_notification(User.find(1), message: :notice_account_password_updated).deliver
+ mail = last_email
+ assert_not_nil mail
+ assert_mail_body_match '192.168.1.1', mail
+ assert_mail_body_match I18n.t(:notice_account_password_updated), mail
+ assert_select_email do
+ assert_select "h1", false
+ assert_select "a", false
+ end
+ end
+ end
+
+ def test_security_notification_should_include_title
+ set_language_if_valid User.find(2).language
+ with_settings :emails_footer => "footer without link" do
+ assert Mailer.security_notification(User.find(2),
+ message: :notice_account_password_updated,
+ title: :label_my_account
+ ).deliver
+ assert_select_email do
+ assert_select "a", false
+ assert_select "h1", :text => I18n.t(:label_my_account)
+ end
+ end
+ end
+
+ def test_security_notification_should_include_link
+ set_language_if_valid User.find(3).language
+ with_settings :emails_footer => "footer without link" do
+ assert Mailer.security_notification(User.find(3),
+ message: :notice_account_password_updated,
+ title: :label_my_account,
+ url: {controller: 'my', action: 'account'}
+ ).deliver
+ assert_select_email do
+ assert_select "h1", false
+ assert_select 'a[href=?]', 'http://mydomain.foo/my/account', :text => I18n.t(:label_my_account)
+ end
+ end
+ end
+
def test_mailer_should_not_change_locale
# Set current language to italian
set_language_if_valid 'it'