diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2009-12-13 14:26:54 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2009-12-13 14:26:54 +0000 |
commit | bb477a3a0fe71f0e15b78b6e0fafb017065fba26 (patch) | |
tree | 5fe5daa3d87fa80c93b0e77bc95552079a1389c5 /test | |
parent | 6610bb6b6cbb1ef72787542063359de04fbab6be (diff) | |
download | redmine-bb477a3a0fe71f0e15b78b6e0fafb017065fba26.tar.gz redmine-bb477a3a0fe71f0e15b78b6e0fafb017065fba26.zip |
Make sure users don't get notified for thing they can not view (#3589).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3169 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test')
-rw-r--r-- | test/unit/mailer_test.rb | 46 |
1 files changed, 43 insertions, 3 deletions
diff --git a/test/unit/mailer_test.rb b/test/unit/mailer_test.rb index b8ff4f003..dfc6caf88 100644 --- a/test/unit/mailer_test.rb +++ b/test/unit/mailer_test.rb @@ -147,7 +147,7 @@ class MailerTest < ActiveSupport::TestCase def test_message_posted_message_id ActionMailer::Base.deliveries.clear message = Message.find(1) - Mailer.deliver_message_posted(message, message.author.mail) + Mailer.deliver_message_posted(message) mail = ActionMailer::Base.deliveries.last assert_not_nil mail assert_equal Mailer.message_id_for(message), mail.message_id @@ -157,13 +157,47 @@ class MailerTest < ActiveSupport::TestCase def test_reply_posted_message_id ActionMailer::Base.deliveries.clear message = Message.find(3) - Mailer.deliver_message_posted(message, message.author.mail) + Mailer.deliver_message_posted(message) mail = ActionMailer::Base.deliveries.last assert_not_nil mail assert_equal Mailer.message_id_for(message), mail.message_id assert_equal Mailer.message_id_for(message.parent), mail.references.first.to_s end + context("#issue_add") do + setup do + ActionMailer::Base.deliveries.clear + Setting.bcc_recipients = '1' + @issue = Issue.find(1) + end + + should "notify project members" do + assert Mailer.deliver_issue_add(@issue) + assert last_email.bcc.include?('dlopper@somenet.foo') + end + + should "not notify project members that are not allow to view the issue" do + Role.find(2).remove_permission!(:view_issues) + assert Mailer.deliver_issue_add(@issue) + assert !last_email.bcc.include?('dlopper@somenet.foo') + end + + should "notify issue watchers" do + user = User.find(9) + Watcher.create!(:watchable => @issue, :user => user) + assert Mailer.deliver_issue_add(@issue) + assert last_email.bcc.include?(user.mail) + end + + should "not notify watchers not allowed to view the issue" do + user = User.find(9) + Watcher.create!(:watchable => @issue, :user => user) + Role.non_member.remove_permission!(:view_issues) + assert Mailer.deliver_issue_add(@issue) + assert !last_email.bcc.include?(user.mail) + end + end + # test mailer methods for each language def test_issue_add issue = Issue.find(1) @@ -211,7 +245,7 @@ class MailerTest < ActiveSupport::TestCase recipients = recipients.compact.uniq valid_languages.each do |lang| Setting.default_language = lang.to_s - assert Mailer.deliver_message_posted(message, recipients) + assert Mailer.deliver_message_posted(message) end end @@ -256,4 +290,10 @@ class MailerTest < ActiveSupport::TestCase assert mail.bcc.include?('dlopper@somenet.foo') assert mail.body.include?('Bug #3: Error 281 when updating a recipe') end + + def last_email + mail = ActionMailer::Base.deliveries.last + assert_not_nil mail + mail + end end |