summaryrefslogtreecommitdiffstats
path: root/test/unit/mailer_test.rb
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2015-01-17 14:14:12 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2015-01-17 14:14:12 +0000
commite3618bdbecd9b5d86eb6d2c8c256ba3fcdf05189 (patch)
tree3b54c10eecece6cc2674491a76a4e5e932d82d1e /test/unit/mailer_test.rb
parent7f29c2fd88f271ac59f1c10b90942fec57b35ae2 (diff)
downloadredmine-e3618bdbecd9b5d86eb6d2c8c256ba3fcdf05189.tar.gz
redmine-e3618bdbecd9b5d86eb6d2c8c256ba3fcdf05189.zip
Add support for multiple email addresses per user (#4244).
git-svn-id: http://svn.redmine.org/redmine/trunk@13886 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/unit/mailer_test.rb')
-rw-r--r--test/unit/mailer_test.rb34
1 files changed, 33 insertions, 1 deletions
diff --git a/test/unit/mailer_test.rb b/test/unit/mailer_test.rb
index 9728387a4..b020e5303 100644
--- a/test/unit/mailer_test.rb
+++ b/test/unit/mailer_test.rb
@@ -20,7 +20,7 @@ require File.expand_path('../../test_helper', __FILE__)
class MailerTest < ActiveSupport::TestCase
include Redmine::I18n
include ActionDispatch::Assertions::SelectorAssertions
- fixtures :projects, :enabled_modules, :issues, :users, :members,
+ fixtures :projects, :enabled_modules, :issues, :users, :email_addresses, :members,
:member_roles, :roles, :documents, :attachments, :news,
:tokens, :journals, :journal_details, :changesets,
:trackers, :projects_trackers,
@@ -298,6 +298,14 @@ class MailerTest < ActiveSupport::TestCase
assert last_email.bcc.include?('dlopper@somenet.foo')
end
+ def test_issue_add_should_send_mail_to_all_user_email_address
+ EmailAddress.create!(:user_id => 3, :address => 'otheremail@somenet.foo')
+ issue = Issue.find(1)
+ assert Mailer.deliver_issue_add(issue)
+ assert last_email.bcc.include?('dlopper@somenet.foo')
+ assert last_email.bcc.include?('otheremail@somenet.foo')
+ end
+
test "#issue_add should not notify project members that are not allow to view the issue" do
issue = Issue.find(1)
Role.find(2).remove_permission!(:view_issues)
@@ -771,6 +779,30 @@ class MailerTest < ActiveSupport::TestCase
ActionMailer::Base.delivery_method = :test
end
+ def test_email_addresses_should_keep_addresses
+ assert_equal ["foo@example.net"],
+ Mailer.email_addresses("foo@example.net")
+
+ assert_equal ["foo@example.net", "bar@example.net"],
+ Mailer.email_addresses(["foo@example.net", "bar@example.net"])
+ end
+
+ def test_email_addresses_should_replace_users_with_their_email_addresses
+ assert_equal ["admin@somenet.foo"],
+ Mailer.email_addresses(User.find(1))
+
+ assert_equal ["admin@somenet.foo", "jsmith@somenet.foo"],
+ Mailer.email_addresses(User.where(:id => [1,2])).sort
+ end
+
+ def test_email_addresses_should_include_notified_emails_addresses_only
+ EmailAddress.create!(:user_id => 2, :address => "another@somenet.foo", :notify => false)
+ EmailAddress.create!(:user_id => 2, :address => "another2@somenet.foo")
+
+ assert_equal ["another2@somenet.foo", "jsmith@somenet.foo"],
+ Mailer.email_addresses(User.find(2)).sort
+ end
+
private
def last_email