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),
'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
:issue_categories,
:custom_fields,
:custom_fields_trackers,
+ :custom_fields_projects,
:boards,
:messages
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
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'
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
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