@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]) }
@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
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