Commit 50de7754 authored by jplang's avatar jplang

MailHandler: Match assignee on the full display name (#11552).

git-svn-id: https://svn.redmine.org/redmine/trunk@10236 e93f8b46-1217-0410-a6f0-8f06a7374b81
parent 9d3fe10f
...@@ -468,7 +468,7 @@ class MailHandler < ActionMailer::Base ...@@ -468,7 +468,7 @@ class MailHandler < ActionMailer::Base
} }
end end
if assignee.nil? if assignee.nil?
assignee ||= assignable.detect {|a| a.is_a?(Group) && a.name.downcase == keyword} assignee ||= assignable.detect {|a| a.name.downcase == keyword}
end end
assignee assignee
end end
......
...@@ -12,7 +12,8 @@ module ObjectHelpers ...@@ -12,7 +12,8 @@ module ObjectHelpers
user user
end end
def User.add_to_project(user, project, roles) def User.add_to_project(user, project, roles=nil)
roles = Role.find(1) if roles.nil?
roles = [roles] unless roles.is_a?(Array) roles = [roles] unless roles.is_a?(Array)
Member.create!(:principal => user, :project => project, :roles => roles) Member.create!(:principal => user, :project => project, :roles => roles)
end end
......
...@@ -194,6 +194,16 @@ class MailHandlerTest < ActiveSupport::TestCase ...@@ -194,6 +194,16 @@ class MailHandlerTest < ActiveSupport::TestCase
assert_equal '2', issue.custom_field_value(field) assert_equal '2', issue.custom_field_value(field)
end end
def test_add_issue_should_match_assignee_on_display_name
user = User.generate!(:firstname => 'Foo Bar', :lastname => 'Foo Baz')
User.add_to_project(user, Project.find(2))
issue = submit_email('ticket_on_given_project.eml') do |email|
email.sub!(/^Assigned to.*$/, 'Assigned to: Foo Bar Foo baz')
end
assert issue.is_a?(Issue)
assert_equal user, issue.assigned_to
end
def test_add_issue_with_cc def test_add_issue_with_cc
issue = submit_email('ticket_with_cc.eml', :issue => {:project => 'ecookbook'}) issue = submit_email('ticket_with_cc.eml', :issue => {:project => 'ecookbook'})
assert issue.is_a?(Issue) assert issue.is_a?(Issue)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment