Add email notification to IssuesController#edit.
git-svn-id: http://redmine.rubyforge.org/svn/trunk@1018 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
5f871e9657
commit
a456225852
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue