]> source.dussan.org Git - redmine.git/commitdiff
Add email notification to IssuesController#edit.
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Wed, 19 Dec 2007 22:09:31 +0000 (22:09 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Wed, 19 Dec 2007 22:09:31 +0000 (22:09 +0000)
git-svn-id: http://redmine.rubyforge.org/svn/trunk@1018 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/controllers/issues_controller.rb
test/functional/issues_controller_test.rb

index 78bcf76a7d45760c107bd6c30117b7d7ae552750..f202e9bbafa129dcb9ff8ac038bd02c8f7f82cb1 100644 (file)
@@ -96,7 +96,7 @@ class IssuesController < ApplicationController
       @custom_values = @project.custom_fields_for_issues(@issue.tracker).collect { |x| @issue.custom_values.find_by_custom_field_id(x.id) || CustomValue.new(:custom_field => x, :customized => @issue) }
     else
       begin
-        @issue.init_journal(User.current)
+        journal = @issue.init_journal(User.current)
         # Retrieve custom fields and values
         if params["custom_fields"]
           @custom_values = @project.custom_fields_for_issues(@issue.tracker).collect { |x| CustomValue.new(:custom_field => x, :customized => @issue, :value => params["custom_fields"][x.id.to_s]) }
@@ -105,6 +105,7 @@ class IssuesController < ApplicationController
         @issue.attributes = params[:issue]
         if @issue.save
           flash[:notice] = l(:notice_successful_update)
+          Mailer.deliver_issue_edit(journal) if Setting.notified_events.include?('issue_updated')
           redirect_to(params[:back_to] || {:action => 'show', :id => @issue})
         end
       rescue ActiveRecord::StaleObjectError
index ebcf78f2403e7238341d771253492d0f07895d59..06d2f1029db6424f74a11f87f6f6d5ac8a60727b 100644 (file)
@@ -112,9 +112,21 @@ class IssuesControllerTest < Test::Unit::TestCase
 
   def test_post_edit
     @request.session[:user_id] = 2
-    post :edit, :id => 1, :issue => {:subject => 'Modified subject'}
+    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}
     assert_redirected_to 'issues/show/1'
-    assert_equal 'Modified subject', Issue.find(1).subject
+    issue.reload
+    assert_equal new_subject, issue.subject
+    
+    mail = ActionMailer::Base.deliveries.last
+    assert_kind_of TMail::Mail, mail
+    assert mail.subject.starts_with?("[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}]")
+    assert mail.body.include?("Subject changed from #{old_subject} to #{new_subject}")
   end
   
   def test_post_change_status