diff options
author | Eric Davis <edavis@littlestreamsoftware.com> | 2009-03-28 00:38:57 +0000 |
---|---|---|
committer | Eric Davis <edavis@littlestreamsoftware.com> | 2009-03-28 00:38:57 +0000 |
commit | b4be8849c0de81841c458c0f059787a9cc9bc022 (patch) | |
tree | 2db816db1cb3cf2fd0761f1e3ad0bc1373f9f12e /test/functional | |
parent | 3557e767e0b0c1e9fd7f97414a92f3d9dc00d98e (diff) | |
download | redmine-b4be8849c0de81841c458c0f059787a9cc9bc022.tar.gz redmine-b4be8849c0de81841c458c0f059787a9cc9bc022.zip |
Added observers to watch model objects for mail delivery instead of calling Mailer.
* Added an IssueObserver to watch when Issues are created
* Added a JournalObserver to watch when Journals are created (Issue updates)
* Added a NewsObserver for News items.
* Added a DocumentObserver for Document notifications.
* Setup IssuesController#new to use the IssueObserver.
* Setup IssuesController#edit to use the IssueObserver.
* Setup IssuesController#bulk_edit to use the JournalObserver.
* Removed the Mailer call in Changeset#scan_commit_for_issue_ids, the
JournalObserver will handle it.
* Removed Mailer calls in MailHandler in favor of the Observers.
#2659
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2637 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/functional')
-rw-r--r-- | test/functional/documents_controller_test.rb | 3 | ||||
-rw-r--r-- | test/functional/issues_controller_test.rb | 45 | ||||
-rw-r--r-- | test/functional/news_controller_test.rb | 4 |
3 files changed, 52 insertions, 0 deletions
diff --git a/test/functional/documents_controller_test.rb b/test/functional/documents_controller_test.rb index 2ad94aacf..b5788c776 100644 --- a/test/functional/documents_controller_test.rb +++ b/test/functional/documents_controller_test.rb @@ -66,6 +66,8 @@ class DocumentsControllerTest < Test::Unit::TestCase end def test_new_with_one_attachment + ActionMailer::Base.deliveries.clear + Setting.notified_events << 'document_added' @request.session[:user_id] = 2 set_tmp_attachments_directory @@ -82,6 +84,7 @@ class DocumentsControllerTest < Test::Unit::TestCase assert_equal Enumeration.find(2), document.category assert_equal 1, document.attachments.size assert_equal 'testfile.txt', document.attachments.first.filename + assert_equal 1, ActionMailer::Base.deliveries.size end def test_edit_routing diff --git a/test/functional/issues_controller_test.rb b/test/functional/issues_controller_test.rb index 9dd188011..0df66abdb 100644 --- a/test/functional/issues_controller_test.rb +++ b/test/functional/issues_controller_test.rb @@ -503,6 +503,21 @@ class IssuesControllerTest < Test::Unit::TestCase assert [mail.bcc, mail.cc].flatten.include?(User.find(3).mail) end + def test_post_new_should_send_a_notification + ActionMailer::Base.deliveries.clear + @request.session[:user_id] = 2 + post :new, :project_id => 1, + :issue => {:tracker_id => 3, + :subject => 'This is the test_new issue', + :description => 'This is the description', + :priority_id => 5, + :estimated_hours => '', + :custom_field_values => {'2' => 'Value for field 2'}} + assert_redirected_to :action => 'show' + + assert_equal 1, ActionMailer::Base.deliveries.size + end + def test_post_should_preserve_fields_values_on_validation_failure @request.session[:user_id] = 2 post :new, :project_id => 1, @@ -760,6 +775,20 @@ class IssuesControllerTest < Test::Unit::TestCase # No email should be sent assert ActionMailer::Base.deliveries.empty? end + + def test_post_edit_should_send_a_notification + @request.session[:user_id] = 2 + ActionMailer::Base.deliveries.clear + issue = Issue.find(1) + old_subject = issue.subject + new_subject = 'Subject modified by IssuesControllerTest#test_post_edit' + + post :edit, :id => 1, :issue => {:subject => new_subject, + :priority_id => '6', + :category_id => '1' # no change + } + assert_equal 1, ActionMailer::Base.deliveries.size + end def test_post_edit_with_invalid_spent_time @request.session[:user_id] = 2 @@ -797,6 +826,22 @@ class IssuesControllerTest < Test::Unit::TestCase assert_equal 1, journal.details.size end + def test_bullk_edit_should_send_a_notification + @request.session[:user_id] = 2 + ActionMailer::Base.deliveries.clear + post(:bulk_edit, + { + :ids => [1, 2], + :priority_id => 7, + :assigned_to_id => '', + :custom_field_values => {'2' => ''}, + :notes => 'Bulk editing' + }) + + assert_response 302 + assert_equal 2, ActionMailer::Base.deliveries.size + end + def test_bulk_edit_custom_field @request.session[:user_id] = 2 # update issues priority diff --git a/test/functional/news_controller_test.rb b/test/functional/news_controller_test.rb index 009e58c73..22ad2d241 100644 --- a/test/functional/news_controller_test.rb +++ b/test/functional/news_controller_test.rb @@ -112,6 +112,9 @@ class NewsControllerTest < Test::Unit::TestCase end def test_post_new + ActionMailer::Base.deliveries.clear + Setting.notified_events << 'news_added' + @request.session[:user_id] = 2 post :new, :project_id => 1, :news => { :title => 'NewsControllerTest', :description => 'This is the description', @@ -123,6 +126,7 @@ class NewsControllerTest < Test::Unit::TestCase assert_equal 'This is the description', news.description assert_equal User.find(2), news.author assert_equal Project.find(1), news.project + assert_equal 1, ActionMailer::Base.deliveries.size end def test_edit_routing |