Fixed: Tracker reset to default when replying to an issue email (#7197).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4575 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
df9ea24136
commit
21c0b868ae
|
@ -256,8 +256,8 @@ class MailHandler < ActionMailer::Base
|
|||
assigned_to = (k = get_keyword(:assigned_to, :override => true)) && find_user_from_keyword(k)
|
||||
assigned_to = nil if assigned_to && !issue.assignable_users.include?(assigned_to)
|
||||
|
||||
{
|
||||
'tracker_id' => ((k = get_keyword(:tracker)) && issue.project.trackers.find_by_name(k).try(:id)) || issue.project.trackers.find(:first).try(:id),
|
||||
attrs = {
|
||||
'tracker_id' => (k = get_keyword(:tracker)) && issue.project.trackers.find_by_name(k).try(:id),
|
||||
'status_id' => (k = get_keyword(:status)) && IssueStatus.find_by_name(k).try(:id),
|
||||
'priority_id' => (k = get_keyword(:priority)) && IssuePriority.find_by_name(k).try(:id),
|
||||
'category_id' => (k = get_keyword(:category)) && issue.project.issue_categories.find_by_name(k).try(:id),
|
||||
|
@ -268,6 +268,12 @@ class MailHandler < ActionMailer::Base
|
|||
'estimated_hours' => get_keyword(:estimated_hours, :override => true),
|
||||
'done_ratio' => get_keyword(:done_ratio, :override => true, :format => '(\d|10)?0')
|
||||
}.delete_if {|k, v| v.blank? }
|
||||
|
||||
if issue.new_record? && attrs['tracker_id'].nil?
|
||||
attrs['tracker_id'] = issue.project.trackers.find(:first).try(:id)
|
||||
end
|
||||
|
||||
attrs
|
||||
end
|
||||
|
||||
# Returns a Hash of issue custom field values extracted from keywords in the email body
|
||||
|
|
|
@ -29,7 +29,7 @@ Status: Resolved
|
|||
due date: 2010-12-31
|
||||
Start Date:2010-01-01
|
||||
Assigned to: jsmith@somenet.foo
|
||||
searchable field: Updated custom value
|
||||
float field: 52.6
|
||||
|
||||
------=_NextPart_000_0067_01C8D3CE.711F9CC0
|
||||
Content-Type: text/html;
|
||||
|
|
|
@ -36,6 +36,7 @@ class MailHandlerTest < ActiveSupport::TestCase
|
|||
:issue_categories,
|
||||
:custom_fields,
|
||||
:custom_fields_trackers,
|
||||
:custom_fields_projects,
|
||||
:boards,
|
||||
:messages
|
||||
|
||||
|
@ -53,9 +54,10 @@ class MailHandlerTest < ActiveSupport::TestCase
|
|||
assert issue.is_a?(Issue)
|
||||
assert !issue.new_record?
|
||||
issue.reload
|
||||
assert_equal Project.find(2), issue.project
|
||||
assert_equal issue.project.trackers.first, issue.tracker
|
||||
assert_equal 'New ticket on a given project', issue.subject
|
||||
assert_equal User.find_by_login('jsmith'), issue.author
|
||||
assert_equal Project.find(2), issue.project
|
||||
assert_equal IssueStatus.find_by_name('Resolved'), issue.status
|
||||
assert issue.description.include?('Lorem ipsum dolor sit amet, consectetuer adipiscing elit.')
|
||||
assert_equal '2010-01-01', issue.start_date.to_s
|
||||
|
@ -73,6 +75,15 @@ class MailHandlerTest < ActiveSupport::TestCase
|
|||
assert_not_nil mail
|
||||
assert mail.subject.include?('New ticket on a given project')
|
||||
end
|
||||
|
||||
def test_add_issue_with_default_tracker
|
||||
# This email contains: 'Project: onlinestore'
|
||||
issue = submit_email('ticket_on_given_project.eml', :issue => {:tracker => 'Support request'})
|
||||
assert issue.is_a?(Issue)
|
||||
assert !issue.new_record?
|
||||
issue.reload
|
||||
assert_equal 'Support request', issue.tracker.name
|
||||
end
|
||||
|
||||
def test_add_issue_with_status
|
||||
# This email contains: 'Project: onlinestore' and 'Status: Resolved'
|
||||
|
@ -290,6 +301,7 @@ class MailHandlerTest < ActiveSupport::TestCase
|
|||
assert_equal User.find_by_login('jsmith'), journal.user
|
||||
assert_equal Issue.find(2), journal.journalized
|
||||
assert_match /This is reply/, journal.notes
|
||||
assert_equal 'Feature request', journal.issue.tracker.name
|
||||
end
|
||||
|
||||
def test_add_issue_note_with_attribute_changes
|
||||
|
@ -300,11 +312,12 @@ class MailHandlerTest < ActiveSupport::TestCase
|
|||
assert_equal User.find_by_login('jsmith'), journal.user
|
||||
assert_equal Issue.find(2), journal.journalized
|
||||
assert_match /This is reply/, journal.notes
|
||||
assert_equal 'Feature request', journal.issue.tracker.name
|
||||
assert_equal IssueStatus.find_by_name("Resolved"), issue.status
|
||||
assert_equal '2010-01-01', issue.start_date.to_s
|
||||
assert_equal '2010-12-31', issue.due_date.to_s
|
||||
assert_equal User.find_by_login('jsmith'), issue.assigned_to
|
||||
assert_equal 'Updated custom value', issue.custom_value_for(CustomField.find_by_name('Searchable field')).value
|
||||
assert_equal "52.6", issue.custom_value_for(CustomField.find_by_name('Float field')).value
|
||||
end
|
||||
|
||||
def test_add_issue_note_should_send_email_notification
|
||||
|
|
Loading…
Reference in New Issue