From 5969df81424968af69cc7b584242d48bf7d5c51e Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sun, 26 Aug 2012 09:03:17 +0000 Subject: [PATCH] MailHandler: Match assignee on the full display name (#11552). git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10236 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/models/mail_handler.rb | 2 +- test/object_helpers.rb | 3 ++- test/unit/mail_handler_test.rb | 10 ++++++++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/app/models/mail_handler.rb b/app/models/mail_handler.rb index 01cf8d74f..8a5925cab 100644 --- a/app/models/mail_handler.rb +++ b/app/models/mail_handler.rb @@ -468,7 +468,7 @@ class MailHandler < ActionMailer::Base } end if assignee.nil? - assignee ||= assignable.detect {|a| a.is_a?(Group) && a.name.downcase == keyword} + assignee ||= assignable.detect {|a| a.name.downcase == keyword} end assignee end diff --git a/test/object_helpers.rb b/test/object_helpers.rb index 85c6d139c..42dfdecda 100644 --- a/test/object_helpers.rb +++ b/test/object_helpers.rb @@ -12,7 +12,8 @@ module ObjectHelpers user 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) Member.create!(:principal => user, :project => project, :roles => roles) end diff --git a/test/unit/mail_handler_test.rb b/test/unit/mail_handler_test.rb index 32646fcdd..49b5d896f 100644 --- a/test/unit/mail_handler_test.rb +++ b/test/unit/mail_handler_test.rb @@ -194,6 +194,16 @@ class MailHandlerTest < ActiveSupport::TestCase assert_equal '2', issue.custom_field_value(field) 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 issue = submit_email('ticket_with_cc.eml', :issue => {:project => 'ecookbook'}) assert issue.is_a?(Issue) -- 2.39.5