Mercurial > hg > soundsoftware-site
diff test/unit/mailer_test.rb @ 1298:4f746d8966dd redmine_2.3_integration
Merge from redmine-2.3 branch to create new branch redmine-2.3-integration
author | Chris Cannam |
---|---|
date | Fri, 14 Jun 2013 09:28:30 +0100 |
parents | 622f24f53b42 |
children |
line wrap: on
line diff
--- a/test/unit/mailer_test.rb Fri Jun 14 09:07:32 2013 +0100 +++ b/test/unit/mailer_test.rb Fri Jun 14 09:28:30 2013 +0100 @@ -1,5 +1,5 @@ # Redmine - project management software -# Copyright (C) 2006-2012 Jean-Philippe Lang +# Copyright (C) 2006-2013 Jean-Philippe Lang # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -210,7 +210,7 @@ end def test_should_not_send_email_without_recipient - news = News.find(:first) + news = News.first user = news.author # Remove members except news author news.project.memberships.each {|m| m.destroy unless m.user == user} @@ -279,44 +279,40 @@ end end - context("#issue_add") do - setup do - ActionMailer::Base.deliveries.clear - Setting.bcc_recipients = '1' - @issue = Issue.find(1) - end + test "#issue_add should notify project members" do + issue = Issue.find(1) + assert Mailer.issue_add(issue).deliver + assert last_email.bcc.include?('dlopper@somenet.foo') + end - should "notify project members" do - assert Mailer.issue_add(@issue).deliver - assert last_email.bcc.include?('dlopper@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) + assert Mailer.issue_add(issue).deliver + 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.issue_add(@issue).deliver - assert !last_email.bcc.include?('dlopper@somenet.foo') - end + test "#issue_add should notify issue watchers" do + issue = Issue.find(1) + user = User.find(9) + # minimal email notification options + user.pref[:no_self_notified] = '1' + user.pref.save + user.mail_notification = false + user.save - should "notify issue watchers" do - user = User.find(9) - # minimal email notification options - user.pref[:no_self_notified] = '1' - user.pref.save - user.mail_notification = false - user.save + Watcher.create!(:watchable => issue, :user => user) + assert Mailer.issue_add(issue).deliver + assert last_email.bcc.include?(user.mail) + end - Watcher.create!(:watchable => @issue, :user => user) - assert Mailer.issue_add(@issue).deliver - 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.issue_add(@issue).deliver - assert !last_email.bcc.include?(user.mail) - end + test "#issue_add should not notify watchers not allowed to view the issue" do + issue = Issue.find(1) + user = User.find(9) + Watcher.create!(:watchable => issue, :user => user) + Role.non_member.remove_permission!(:view_issues) + assert Mailer.issue_add(issue).deliver + assert !last_email.bcc.include?(user.mail) end # test mailer methods for each language @@ -402,7 +398,7 @@ end def test_news_added - news = News.find(:first) + news = News.first valid_languages.each do |lang| Setting.default_language = lang.to_s assert Mailer.news_added(news).deliver @@ -418,7 +414,7 @@ end def test_message_posted - message = Message.find(:first) + message = Message.first recipients = ([message.root] + message.root.children).collect {|m| m.author.mail if m.author} recipients = recipients.compact.uniq valid_languages.each do |lang|