annotate test/unit/journal_observer_test.rb @ 855:7294e8db2515 bug_162

Close obsolete branch bug_162
author Chris Cannam
date Thu, 14 Jul 2011 11:59:19 +0100
parents cbce1fd3b1b7
children 433d4f72a19b
rev   line source
Chris@441 1 # Redmine - project management software
Chris@441 2 # Copyright (C) 2006-2011 Jean-Philippe Lang
chris@37 3 #
chris@37 4 # This program is free software; you can redistribute it and/or
chris@37 5 # modify it under the terms of the GNU General Public License
chris@37 6 # as published by the Free Software Foundation; either version 2
chris@37 7 # of the License, or (at your option) any later version.
Chris@441 8 #
chris@37 9 # This program is distributed in the hope that it will be useful,
chris@37 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
chris@37 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
chris@37 12 # GNU General Public License for more details.
Chris@441 13 #
chris@37 14 # You should have received a copy of the GNU General Public License
chris@37 15 # along with this program; if not, write to the Free Software
chris@37 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
chris@37 17
Chris@119 18 require File.expand_path('../../test_helper', __FILE__)
chris@37 19
chris@37 20 class JournalObserverTest < ActiveSupport::TestCase
chris@37 21 fixtures :issues, :issue_statuses, :journals, :journal_details
chris@37 22
chris@37 23 def setup
chris@37 24 ActionMailer::Base.deliveries.clear
chris@37 25 @journal = Journal.find 1
chris@37 26 end
chris@37 27
chris@37 28 # context: issue_updated notified_events
chris@37 29 def test_create_should_send_email_notification_with_issue_updated
chris@37 30 Setting.notified_events = ['issue_updated']
chris@37 31 issue = Issue.find(:first)
chris@37 32 user = User.find(:first)
chris@37 33 journal = issue.init_journal(user, issue)
chris@37 34
chris@37 35 assert journal.save
chris@37 36 assert_equal 1, ActionMailer::Base.deliveries.size
chris@37 37 end
chris@37 38
Chris@441 39 def test_create_should_not_send_email_notification_with_notify_set_to_false
Chris@441 40 Setting.notified_events = ['issue_updated']
Chris@441 41 issue = Issue.find(:first)
Chris@441 42 user = User.find(:first)
Chris@441 43 journal = issue.init_journal(user, issue)
Chris@441 44 journal.notify = false
Chris@441 45
Chris@441 46 assert journal.save
Chris@441 47 assert_equal 0, ActionMailer::Base.deliveries.size
Chris@441 48 end
Chris@441 49
chris@37 50 def test_create_should_not_send_email_notification_without_issue_updated
chris@37 51 Setting.notified_events = []
chris@37 52 issue = Issue.find(:first)
chris@37 53 user = User.find(:first)
chris@37 54 journal = issue.init_journal(user, issue)
chris@37 55
chris@37 56 assert journal.save
chris@37 57 assert_equal 0, ActionMailer::Base.deliveries.size
chris@37 58 end
chris@37 59
chris@37 60 # context: issue_note_added notified_events
chris@37 61 def test_create_should_send_email_notification_with_issue_note_added
chris@37 62 Setting.notified_events = ['issue_note_added']
chris@37 63 issue = Issue.find(:first)
chris@37 64 user = User.find(:first)
chris@37 65 journal = issue.init_journal(user, issue)
chris@37 66 journal.notes = 'This update has a note'
chris@37 67
chris@37 68 assert journal.save
chris@37 69 assert_equal 1, ActionMailer::Base.deliveries.size
chris@37 70 end
chris@37 71
chris@37 72 def test_create_should_not_send_email_notification_without_issue_note_added
chris@37 73 Setting.notified_events = []
chris@37 74 issue = Issue.find(:first)
chris@37 75 user = User.find(:first)
chris@37 76 journal = issue.init_journal(user, issue)
chris@37 77 journal.notes = 'This update has a note'
Chris@441 78
chris@37 79 assert journal.save
chris@37 80 assert_equal 0, ActionMailer::Base.deliveries.size
chris@37 81 end
chris@37 82
chris@37 83 # context: issue_status_updated notified_events
chris@37 84 def test_create_should_send_email_notification_with_issue_status_updated
chris@37 85 Setting.notified_events = ['issue_status_updated']
chris@37 86 issue = Issue.find(:first)
chris@37 87 user = User.find(:first)
chris@37 88 issue.init_journal(user, issue)
chris@37 89 issue.status = IssueStatus.last
chris@37 90
chris@37 91 assert issue.save
chris@37 92 assert_equal 1, ActionMailer::Base.deliveries.size
chris@37 93 end
chris@37 94
chris@37 95 def test_create_should_not_send_email_notification_without_issue_status_updated
chris@37 96 Setting.notified_events = []
chris@37 97 issue = Issue.find(:first)
chris@37 98 user = User.find(:first)
chris@37 99 issue.init_journal(user, issue)
chris@37 100 issue.status = IssueStatus.last
Chris@441 101
chris@37 102 assert issue.save
chris@37 103 assert_equal 0, ActionMailer::Base.deliveries.size
chris@37 104 end
chris@37 105
chris@37 106 # context: issue_priority_updated notified_events
chris@37 107 def test_create_should_send_email_notification_with_issue_priority_updated
chris@37 108 Setting.notified_events = ['issue_priority_updated']
chris@37 109 issue = Issue.find(:first)
chris@37 110 user = User.find(:first)
chris@37 111 issue.init_journal(user, issue)
chris@37 112 issue.priority = IssuePriority.last
chris@37 113
chris@37 114 assert issue.save
chris@37 115 assert_equal 1, ActionMailer::Base.deliveries.size
chris@37 116 end
chris@37 117
chris@37 118 def test_create_should_not_send_email_notification_without_issue_priority_updated
chris@37 119 Setting.notified_events = []
chris@37 120 issue = Issue.find(:first)
chris@37 121 user = User.find(:first)
chris@37 122 issue.init_journal(user, issue)
chris@37 123 issue.priority = IssuePriority.last
Chris@441 124
chris@37 125 assert issue.save
chris@37 126 assert_equal 0, ActionMailer::Base.deliveries.size
chris@37 127 end
chris@37 128 end