]> source.dussan.org Git - redmine.git/commitdiff
replace Mailer deliver syntax to Rails3 style
authorToshi MARUYAMA <marutosijp2@yahoo.co.jp>
Sat, 5 May 2012 13:07:12 +0000 (13:07 +0000)
committerToshi MARUYAMA <marutosijp2@yahoo.co.jp>
Sat, 5 May 2012 13:07:12 +0000 (13:07 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@9638 e93f8b46-1217-0410-a6f0-8f06a7374b81

16 files changed:
app/controllers/account_controller.rb
app/controllers/admin_controller.rb
app/controllers/documents_controller.rb
app/controllers/files_controller.rb
app/controllers/users_controller.rb
app/models/comment_observer.rb
app/models/document_observer.rb
app/models/issue_observer.rb
app/models/journal_observer.rb
app/models/mail_handler.rb
app/models/message_observer.rb
app/models/news_observer.rb
app/models/wiki_content_observer.rb
lib/tasks/email.rake
test/unit/lib/redmine/hook_test.rb
test/unit/mailer_test.rb

index d44741678226d40baf585ff3c9bda142b9ce799d..fa530087eebfbb8a3e013597f5dda3ffc42f5941 100644 (file)
@@ -68,7 +68,7 @@ class AccountController < ApplicationController
         # create a new token for password recovery
         token = Token.new(:user => user, :action => "recovery")
         if token.save
-          Mailer.deliver_lost_password(token)
+          Mailer.lost_password(token).deliver
           flash[:notice] = l(:notice_account_lost_email_sent)
           redirect_to :action => 'login'
           return
@@ -235,7 +235,7 @@ class AccountController < ApplicationController
   def register_by_email_activation(user, &block)
     token = Token.new(:user => user, :action => "register")
     if user.save and token.save
-      Mailer.deliver_register(token)
+      Mailer.register(token).deliver
       flash[:notice] = l(:notice_account_register_done)
       redirect_to :action => 'login'
     else
@@ -265,7 +265,7 @@ class AccountController < ApplicationController
   def register_manually_by_administrator(user, &block)
     if user.save
       # Sends an email to the administrators
-      Mailer.deliver_account_activation_request(user)
+      Mailer.account_activation_request(user).deliver
       account_pending
     else
       yield if block_given?
index 6e961dad9732e93db2059ad9d5506c6caf364dcc..e8cccca8570ba44a45c53773eca526d5a24b8fc1 100644 (file)
@@ -63,7 +63,7 @@ class AdminController < ApplicationController
     # Force ActionMailer to raise delivery errors so we can catch it
     ActionMailer::Base.raise_delivery_errors = true
     begin
-      @test = Mailer.deliver_test_email(User.current)
+      @test = Mailer.test_email(User.current).deliver
       flash[:notice] = l(:notice_email_sent, User.current.mail)
     rescue Exception => e
       flash[:error] = l(:notice_email_error, e.message)
index 96be5631a5c5994d98a5dfdf8c049727b4f1da43..b3c82eeb0326c53b8b435c583255463d077db940 100644 (file)
@@ -86,7 +86,9 @@ class DocumentsController < ApplicationController
     attachments = Attachment.attach_files(@document, params[:attachments])
     render_attachment_warning_if_needed(@document)
 
-    Mailer.deliver_attachments_added(attachments[:files]) if attachments.present? && attachments[:files].present? && Setting.notified_events.include?('document_added')
+    if attachments.present? && attachments[:files].present? && Setting.notified_events.include?('document_added')
+      Mailer.attachments_added(attachments[:files]).deliver
+    end
     redirect_to :action => 'show', :id => @document
   end
 end
index d21aa5e14a1fe9536ce9f795f8e8ceea6d743ca1..f96cd4a9fb414cd4e2c93625244909668ca8a8d2 100644 (file)
@@ -46,7 +46,7 @@ class FilesController < ApplicationController
     render_attachment_warning_if_needed(container)
 
     if !attachments.empty? && !attachments[:files].blank? && Setting.notified_events.include?('file_added')
-      Mailer.deliver_attachments_added(attachments[:files])
+      Mailer.attachments_added(attachments[:files]).deliver
     end
     redirect_to project_files_path(@project)
   end
index 44aa410374fa2dcdc435ee89846eb6473851a126..3b42e7e546d1f2bb7d2864d4f0c8eb8fb01a50b9 100644 (file)
@@ -99,7 +99,7 @@ class UsersController < ApplicationController
       @user.pref.save
       @user.notified_project_ids = (@user.mail_notification == 'selected' ? params[:notified_project_ids] : [])
 
-      Mailer.deliver_account_information(@user, params[:user][:password]) if params[:send_information]
+      Mailer.account_information(@user, params[:user][:password]).deliver if params[:send_information]
 
       respond_to do |format|
         format.html {
@@ -146,9 +146,9 @@ class UsersController < ApplicationController
       @user.notified_project_ids = (@user.mail_notification == 'selected' ? params[:notified_project_ids] : [])
 
       if was_activated
-        Mailer.deliver_account_activated(@user)
+        Mailer.account_activated(@user).deliver
       elsif @user.active? && params[:send_information] && !params[:user][:password].blank? && @user.auth_source_id.nil?
-        Mailer.deliver_account_information(@user, params[:user][:password])
+        Mailer.account_information(@user, params[:user][:password]).deliver
       end
 
       respond_to do |format|
index 07823e44c47d9b7c78d71aa7bc506240e250d98d..e85f3b6c936e01f3bfe878326e4879e12fe7329a 100644 (file)
@@ -18,7 +18,7 @@
 class CommentObserver < ActiveRecord::Observer
   def after_create(comment)
     if comment.commented.is_a?(News) && Setting.notified_events.include?('news_comment_added')
-      Mailer.deliver_news_comment_added(comment)
+      Mailer.news_comment_added(comment).deliver
     end
   end
 end
index a5db33e5ea4b60ef65c2e4ffac789eae1f0193bd..cd0db3d26532a995ed8dd076947a7153ae123acd 100644 (file)
@@ -17,6 +17,6 @@
 
 class DocumentObserver < ActiveRecord::Observer
   def after_create(document)
-    Mailer.deliver_document_added(document) if Setting.notified_events.include?('document_added')
+    Mailer.document_added(document).deliver if Setting.notified_events.include?('document_added')
   end
 end
index 8c42e692e656581469d622701b49549f0c2aadb4..86f5e0c8ec0ad7a5ef61ac594450a8b49f8424e0 100644 (file)
@@ -17,6 +17,6 @@
 
 class IssueObserver < ActiveRecord::Observer
   def after_create(issue)
-    Mailer.deliver_issue_add(issue) if Setting.notified_events.include?('issue_added')
+    Mailer.issue_add(issue).deliver if Setting.notified_events.include?('issue_added')
   end
 end
index 8bd0d33153bfa63a7cc319d685142d5a9438e0b3..f94e5f7c3215fd18add408b2adb6ecb9c575462f 100644 (file)
@@ -23,7 +23,7 @@ class JournalObserver < ActiveRecord::Observer
           (Setting.notified_events.include?('issue_status_updated') && journal.new_status.present?) ||
           (Setting.notified_events.include?('issue_priority_updated') && journal.new_value_for('priority_id').present?)
         )
-      Mailer.deliver_issue_edit(journal)
+      Mailer.issue_edit(journal).deliver
     end
   end
 end
index a63ee1dace5bd615a34621864ad96754fba2ebe3..9e7e3aade235bf8c2b4e9443d6c9b5feb504cfde 100644 (file)
@@ -94,7 +94,7 @@ class MailHandler < ActionMailer::Base
           if logger && logger.info
             logger.info "MailHandler: [#{@user.login}] account created"
           end
-          Mailer.deliver_account_information(@user, @user.password)
+          Mailer.account_information(@user, @user.password).deliver
         else
           if logger && logger.error
             logger.error "MailHandler: could not create account for [#{sender_email}]"
index 6a0f05931e7bf1e254ff5e195d0367b512ac129c..62c564361c08767b5181b92afe9eebd4aef44020 100644 (file)
@@ -17,6 +17,6 @@
 
 class MessageObserver < ActiveRecord::Observer
   def after_create(message)
-    Mailer.deliver_message_posted(message) if Setting.notified_events.include?('message_posted')
+    Mailer.message_posted(message).deliver if Setting.notified_events.include?('message_posted')
   end
 end
index 0fdfe0bac89eb536a5482cfd30b32cacf209e2de..3dd2da2bb08b7878e6a7c923f5b81454ba2717fb 100644 (file)
@@ -17,6 +17,6 @@
 
 class NewsObserver < ActiveRecord::Observer
   def after_create(news)
-    Mailer.deliver_news_added(news) if Setting.notified_events.include?('news_added')
+    Mailer.news_added(news).deliver if Setting.notified_events.include?('news_added')
   end
 end
index 9f37422914762c2096f349e6b7e229062fef19f0..f423044cda5c4fb8653b40c3644780756fa73910 100644 (file)
 
 class WikiContentObserver < ActiveRecord::Observer
   def after_create(wiki_content)
-    Mailer.deliver_wiki_content_added(wiki_content) if Setting.notified_events.include?('wiki_content_added')
+    Mailer.wiki_content_added(wiki_content).deliver if Setting.notified_events.include?('wiki_content_added')
   end
 
   def after_update(wiki_content)
     if wiki_content.text_changed?
-      Mailer.deliver_wiki_content_updated(wiki_content) if Setting.notified_events.include?('wiki_content_updated')
+      Mailer.wiki_content_updated(wiki_content).deliver if Setting.notified_events.include?('wiki_content_updated')
     end
   end
 end
index 5e68080f9be29a213ac34df63295687d1b6c0429..2a8542ebefbe1411a4ba8d59d45a1ee5e40685bd 100644 (file)
@@ -177,7 +177,7 @@ END_DESC
       ActionMailer::Base.raise_delivery_errors = true
       begin
         Mailer.with_synched_deliveries do
-          Mailer.deliver_test_email(user)
+          Mailer.test_email(user).deliver
         end
         puts l(:notice_email_sent, user.mail)
       rescue Exception => e
index 6a8e69a308e28891f8341d271f816058f01bba5e..225d49bdaa8460ae498529ef2de72f64bf8d2754 100644 (file)
@@ -148,14 +148,14 @@ class Redmine::Hook::ManagerTest < ActionView::TestCase
     issue = Issue.find(1)
 
     ActionMailer::Base.deliveries.clear
-    Mailer.deliver_issue_add(issue)
+    Mailer.issue_add(issue).deliver
     mail = ActionMailer::Base.deliveries.last
 
     @hook_module.add_listener(TestLinkToHook)
     hook_helper.call_hook(:view_layouts_base_html_head)
 
     ActionMailer::Base.deliveries.clear
-    Mailer.deliver_issue_add(issue)
+    Mailer.issue_add(issue).deliver
     mail2 = ActionMailer::Base.deliveries.last
 
     assert_equal mail_body(mail), mail_body(mail2)
index d9daec7a7a1ac505c8b9824189dc46252082fda9..483886e58b83c827958cdf4a41957e6039084288 100644 (file)
@@ -42,7 +42,7 @@ class MailerTest < ActiveSupport::TestCase
     Setting.protocol = 'https'
 
     journal = Journal.find(3)
-    assert Mailer.deliver_issue_edit(journal)
+    assert Mailer.issue_edit(journal).deliver
 
     mail = last_email
     assert_not_nil mail
@@ -81,7 +81,7 @@ class MailerTest < ActiveSupport::TestCase
     Setting.protocol = 'http'
 
     journal = Journal.find(3)
-    assert Mailer.deliver_issue_edit(journal)
+    assert Mailer.issue_edit(journal).deliver
 
     mail = last_email
     assert_not_nil mail
@@ -121,7 +121,7 @@ class MailerTest < ActiveSupport::TestCase
     Redmine::Utils.relative_url_root = nil
 
     journal = Journal.find(3)
-    assert Mailer.deliver_issue_edit(journal)
+    assert Mailer.issue_edit(journal).deliver
 
     mail = last_email
     assert_not_nil mail
@@ -158,7 +158,7 @@ class MailerTest < ActiveSupport::TestCase
 
   def test_email_headers
     issue = Issue.find(1)
-    Mailer.deliver_issue_add(issue)
+    Mailer.issue_add(issue).deliver
     mail = last_email
     assert_not_nil mail
     assert_equal 'OOF', mail.header['X-Auto-Response-Suppress'].to_s
@@ -167,7 +167,7 @@ class MailerTest < ActiveSupport::TestCase
 
   def test_email_headers_should_include_sender
     issue = Issue.find(1)
-    Mailer.deliver_issue_add(issue)
+    Mailer.issue_add(issue).deliver
     mail = last_email
     assert_equal issue.author.login, mail.header['X-Redmine-Sender'].to_s
   end
@@ -175,7 +175,7 @@ class MailerTest < ActiveSupport::TestCase
   def test_plain_text_mail
     Setting.plain_text_mail = 1
     journal = Journal.find(2)
-    Mailer.deliver_issue_edit(journal)
+    Mailer.issue_edit(journal).deliver
     mail = last_email
     assert_equal "text/plain; charset=UTF-8", mail.content_type
     assert_equal 0, mail.parts.size
@@ -185,7 +185,7 @@ class MailerTest < ActiveSupport::TestCase
   def test_html_mail
     Setting.plain_text_mail = 0
     journal = Journal.find(2)
-    Mailer.deliver_issue_edit(journal)
+    Mailer.issue_edit(journal).deliver
     mail = last_email
     assert_equal 2, mail.parts.size
     assert mail.encoded.include?('href')
@@ -193,7 +193,7 @@ class MailerTest < ActiveSupport::TestCase
 
   def test_from_header
     with_settings :mail_from => 'redmine@example.net' do
-      Mailer.deliver_test_email(User.find(1))
+      Mailer.test_email(User.find(1)).deliver
     end
     mail = last_email
     assert_equal 'redmine@example.net', mail.from_addrs.first
@@ -201,7 +201,7 @@ class MailerTest < ActiveSupport::TestCase
 
   def test_from_header_with_phrase
     with_settings :mail_from => 'Redmine app <redmine@example.net>' do
-      Mailer.deliver_test_email(User.find(1))
+      Mailer.test_email(User.find(1)).deliver
     end
     mail = last_email
     assert_equal 'redmine@example.net', mail.from_addrs.first
@@ -217,7 +217,7 @@ class MailerTest < ActiveSupport::TestCase
     user.pref[:no_self_notified] = false
     user.pref.save
     User.current = user
-    Mailer.deliver_news_added(news.reload)
+    Mailer.news_added(news.reload).deliver
     assert_equal 1, last_email.bcc.size
 
     # nobody to notify
@@ -225,13 +225,13 @@ class MailerTest < ActiveSupport::TestCase
     user.pref.save
     User.current = user
     ActionMailer::Base.deliveries.clear
-    Mailer.deliver_news_added(news.reload)
+    Mailer.news_added(news.reload).deliver
     assert ActionMailer::Base.deliveries.empty?
   end
 
   def test_issue_add_message_id
     issue = Issue.find(1)
-    Mailer.deliver_issue_add(issue)
+    Mailer.issue_add(issue).deliver
     mail = last_email
     assert_equal Mailer.message_id_for(issue), mail.message_id
     assert_nil mail.references
@@ -239,7 +239,7 @@ class MailerTest < ActiveSupport::TestCase
 
   def test_issue_edit_message_id
     journal = Journal.find(1)
-    Mailer.deliver_issue_edit(journal)
+    Mailer.issue_edit(journal).deliver
     mail = last_email
     assert_equal Mailer.message_id_for(journal), mail.message_id
     assert_include Mailer.message_id_for(journal.issue), mail.references
@@ -252,7 +252,7 @@ class MailerTest < ActiveSupport::TestCase
 
   def test_message_posted_message_id
     message = Message.find(1)
-    Mailer.deliver_message_posted(message)
+    Mailer.message_posted(message).deliver
     mail = last_email
     assert_equal Mailer.message_id_for(message), mail.message_id
     assert_nil mail.references
@@ -266,7 +266,7 @@ class MailerTest < ActiveSupport::TestCase
 
   def test_reply_posted_message_id
     message = Message.find(3)
-    Mailer.deliver_message_posted(message)
+    Mailer.message_posted(message).deliver
     mail = last_email
     assert_equal Mailer.message_id_for(message), mail.message_id
     assert_include Mailer.message_id_for(message.parent), mail.references
@@ -286,13 +286,13 @@ class MailerTest < ActiveSupport::TestCase
     end
 
     should "notify project members" do
-      assert Mailer.deliver_issue_add(@issue)
+      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.deliver_issue_add(@issue)
+      assert Mailer.issue_add(@issue).deliver
       assert !last_email.bcc.include?('dlopper@somenet.foo')
     end
 
@@ -305,7 +305,7 @@ class MailerTest < ActiveSupport::TestCase
       user.save
 
       Watcher.create!(:watchable => @issue, :user => user)
-      assert Mailer.deliver_issue_add(@issue)
+      assert Mailer.issue_add(@issue).deliver
       assert last_email.bcc.include?(user.mail)
     end
 
@@ -313,7 +313,7 @@ class MailerTest < ActiveSupport::TestCase
       user = User.find(9)
       Watcher.create!(:watchable => @issue, :user => user)
       Role.non_member.remove_permission!(:view_issues)
-      assert Mailer.deliver_issue_add(@issue)
+      assert Mailer.issue_add(@issue).deliver
       assert !last_email.bcc.include?(user.mail)
     end
   end
@@ -323,7 +323,7 @@ class MailerTest < ActiveSupport::TestCase
     issue = Issue.find(1)
     valid_languages.each do |lang|
       Setting.default_language = lang.to_s
-      assert Mailer.deliver_issue_add(issue)
+      assert Mailer.issue_add(issue).deliver
     end
   end
 
@@ -331,7 +331,7 @@ class MailerTest < ActiveSupport::TestCase
     journal = Journal.find(1)
     valid_languages.each do |lang|
       Setting.default_language = lang.to_s
-      assert Mailer.deliver_issue_edit(journal)
+      assert Mailer.issue_edit(journal).deliver
     end
   end
 
@@ -339,7 +339,7 @@ class MailerTest < ActiveSupport::TestCase
     document = Document.find(1)
     valid_languages.each do |lang|
       Setting.default_language = lang.to_s
-      assert Mailer.deliver_document_added(document)
+      assert Mailer.document_added(document).deliver
     end
   end
 
@@ -347,13 +347,13 @@ class MailerTest < ActiveSupport::TestCase
     attachements = [ Attachment.find_by_container_type('Document') ]
     valid_languages.each do |lang|
       Setting.default_language = lang.to_s
-      assert Mailer.deliver_attachments_added(attachements)
+      assert Mailer.attachments_added(attachements).deliver
     end
   end
 
   def test_version_file_added
     attachements = [ Attachment.find_by_container_type('Version') ]
-    assert Mailer.deliver_attachments_added(attachements)
+    assert Mailer.attachments_added(attachements).deliver
     assert_not_nil last_email.bcc
     assert last_email.bcc.any?
     assert_select_email do
@@ -363,7 +363,7 @@ class MailerTest < ActiveSupport::TestCase
 
   def test_project_file_added
     attachements = [ Attachment.find_by_container_type('Project') ]
-    assert Mailer.deliver_attachments_added(attachements)
+    assert Mailer.attachments_added(attachements).deliver
     assert_not_nil last_email.bcc
     assert last_email.bcc.any?
     assert_select_email do
@@ -375,7 +375,7 @@ class MailerTest < ActiveSupport::TestCase
     news = News.find(:first)
     valid_languages.each do |lang|
       Setting.default_language = lang.to_s
-      assert Mailer.deliver_news_added(news)
+      assert Mailer.news_added(news).deliver
     end
   end
 
@@ -383,7 +383,7 @@ class MailerTest < ActiveSupport::TestCase
     comment = Comment.find(2)
     valid_languages.each do |lang|
       Setting.default_language = lang.to_s
-      assert Mailer.deliver_news_comment_added(comment)
+      assert Mailer.news_comment_added(comment).deliver
     end
   end
 
@@ -393,7 +393,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)
+      assert Mailer.message_posted(message).deliver
     end
   end
 
@@ -402,7 +402,7 @@ class MailerTest < ActiveSupport::TestCase
     valid_languages.each do |lang|
       Setting.default_language = lang.to_s
       assert_difference 'ActionMailer::Base.deliveries.size' do
-        assert Mailer.deliver_wiki_content_added(content)
+        assert Mailer.wiki_content_added(content).deliver
       end
     end
   end
@@ -412,7 +412,7 @@ class MailerTest < ActiveSupport::TestCase
     valid_languages.each do |lang|
       Setting.default_language = lang.to_s
       assert_difference 'ActionMailer::Base.deliveries.size' do
-        assert Mailer.deliver_wiki_content_updated(content)
+        assert Mailer.wiki_content_updated(content).deliver
       end
     end
   end
@@ -422,7 +422,7 @@ class MailerTest < ActiveSupport::TestCase
     valid_languages.each do |lang|
       user.update_attribute :language, lang.to_s
       user.reload
-      assert Mailer.deliver_account_information(user, 'pAsswORd')
+      assert Mailer.account_information(user, 'pAsswORd').deliver
     end
   end
 
@@ -431,7 +431,7 @@ class MailerTest < ActiveSupport::TestCase
     valid_languages.each do |lang|
       token.user.update_attribute :language, lang.to_s
       token.reload
-      assert Mailer.deliver_lost_password(token)
+      assert Mailer.lost_password(token).deliver
     end
   end
 
@@ -444,7 +444,7 @@ class MailerTest < ActiveSupport::TestCase
       token.user.update_attribute :language, lang.to_s
       token.reload
       ActionMailer::Base.deliveries.clear
-      assert Mailer.deliver_register(token)
+      assert Mailer.register(token).deliver
       mail = last_email
       assert_select_email do
         assert_select "a[href=?]",
@@ -458,7 +458,7 @@ class MailerTest < ActiveSupport::TestCase
     user = User.find(1)
     valid_languages.each do |lang|
       user.update_attribute :language, lang.to_s
-      assert Mailer.deliver_test_email(user)
+      assert Mailer.test_email(user).deliver
     end
   end
 
@@ -504,7 +504,7 @@ class MailerTest < ActiveSupport::TestCase
     # Send an email to a french user
     user = User.find(1)
     user.language = 'fr'
-    Mailer.deliver_account_activated(user)
+    Mailer.account_activated(user).deliver
     mail = last_email
     assert_mail_body_match 'Votre compte', mail
 
@@ -513,7 +513,7 @@ class MailerTest < ActiveSupport::TestCase
 
   def test_with_deliveries_off
     Mailer.with_deliveries false do
-      Mailer.deliver_test_email(User.find(1))
+      Mailer.test_email(User.find(1)).deliver
     end
     assert ActionMailer::Base.deliveries.empty?
     # should restore perform_deliveries
@@ -522,7 +522,7 @@ class MailerTest < ActiveSupport::TestCase
 
   def test_layout_should_include_the_emails_header
     with_settings :emails_header => "*Header content*" do
-      assert Mailer.deliver_test_email(User.find(1))
+      assert Mailer.test_email(User.find(1)).deliver
       assert_select_email do
         assert_select ".header" do
           assert_select "strong", :text => "Header content"