diff -r 2ca61e72c995 app/models/mail_handler.rb --- a/app/models/mail_handler.rb Mon Jul 30 01:32:31 2012 +0000 +++ b/app/models/mail_handler.rb Tue Jul 31 15:29:05 2012 -0400 @@ -470,6 +470,13 @@ if assignee.nil? assignee ||= assignable.detect {|a| a.is_a?(Group) && a.name.downcase == keyword} end + # We're going to do a last-ditch iteration for comined names for an edge-case of spaces in names. + if assignee.nil? && keyword.match(/ /) + assignee ||= assignable.detect { |a| + a.is_a?(User) && + (a.firstname + ' ' + a.lastname).to_s.downcase == keyword + } + end assignee end end diff -r 2ca61e72c995 test/fixtures/mail_handler/ticket_assign_user_with_space_in_name.eml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/fixtures/mail_handler/ticket_assign_user_with_space_in_name.eml Tue Jul 31 15:29:05 2012 -0400 @@ -0,0 +1,19 @@ +Return-Path: +Received: from osiris ([127.0.0.1]) + by OSIRIS + with hMailServer ; Sun, 22 Jun 2008 12:28:07 +0200 +Message-ID: <000501c8d452$a95cd7e0$0a00a8c0@osiris> +From: "John Doe" +To: +Subject: Ticket by unknown user +Date: Sun, 22 Jun 2008 12:28:07 +0200 +MIME-Version: 1.0 +Content-Type: text/plain; + format=flowed; + charset="iso-8859-1"; + reply-type=original +Content-Transfer-Encoding: 7bit + +This is a ticket submitted by an unknown user. + +Assigned to: IS - Operations \ No newline at end of file diff -r 2ca61e72c995 test/unit/mail_handler_test.rb --- a/test/unit/mail_handler_test.rb Mon Jul 30 01:32:31 2012 +0000 +++ b/test/unit/mail_handler_test.rb Tue Jul 31 15:29:05 2012 -0400 @@ -397,6 +397,40 @@ end end end + + # Defect #11552, users with additional spaces in their names cannot be assigned to using their full name. + def test_assign_to_user_with_space_in_name + # Create the reported user "IS - Operations" + created_user = User.new(:mail => 'dashtest@somenet.foo', + :firstname => 'IS -', + :lastname => 'Operations') + created_user.login = 'dashtest' + created_user.save! + + # Add user to project. + project = Project.find_by_identifier('ecookbook') + assert_not_nil project + member = Member.create(:project => project, :user => created_user, :role_ids => [1, 2]) + + # Confirm the user got added correctly. + get_user = User.find_by_login('dashtest') + assert_not_nil get_user + assert_equal 'IS -', get_user.firstname + + # Bring in an anonymous e-mail, assigned to IS - Operations. + issue = submit_email('ticket_assign_user_with_space_in_name.eml', + :allow_override => 'assigned_to', + :issue => { :project => 'ecookbook' }, + :no_permission_check => '1', + :unknown_user => 'accept') + assert issue.is_a?(Issue) + assert !issue.new_record? + issue.save! + + # Reload and check and make sure the user is there. + issue.reload + assert_equal get_user, issue.assigned_to + end def test_add_issue_should_send_email_notification Setting.notified_events = ['issue_added']