summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2010-11-14 13:48:01 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2010-11-14 13:48:01 +0000
commitd7cdd58db6b89711dcd38767093751aa09f19f79 (patch)
treedec932d59f6bc161884d2372d1d2145fd47ff557
parent97a9210483c121639ca576e91f9f6b767400fbf8 (diff)
downloadredmine-d7cdd58db6b89711dcd38767093751aa09f19f79.tar.gz
redmine-d7cdd58db6b89711dcd38767093751aa09f19f79.zip
MailHandler: ignore assignee if invalid.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4404 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r--app/models/mail_handler.rb5
-rw-r--r--test/fixtures/mail_handler/ticket_with_invalid_attributes.eml1
-rw-r--r--test/unit/mail_handler_test.rb2
3 files changed, 7 insertions, 1 deletions
diff --git a/app/models/mail_handler.rb b/app/models/mail_handler.rb
index a5cf21f97..00010059f 100644
--- a/app/models/mail_handler.rb
+++ b/app/models/mail_handler.rb
@@ -253,12 +253,15 @@ class MailHandler < ActionMailer::Base
# Returns a Hash of issue attributes extracted from keywords in the email body
def issue_attributes_from_keywords(issue)
+ 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),
'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),
- 'assigned_to_id' => (k = get_keyword(:assigned_to, :override => true)) && find_user_from_keyword(k).try(:id),
+ 'assigned_to_id' => assigned_to.try(:id),
'fixed_version_id' => (k = get_keyword(:fixed_version, :override => true)) && issue.project.shared_versions.find_by_name(k).try(:id),
'start_date' => get_keyword(:start_date, :override => true, :format => '\d{4}-\d{2}-\d{2}'),
'due_date' => get_keyword(:due_date, :override => true, :format => '\d{4}-\d{2}-\d{2}'),
diff --git a/test/fixtures/mail_handler/ticket_with_invalid_attributes.eml b/test/fixtures/mail_handler/ticket_with_invalid_attributes.eml
index 3b39fb551..4506078d7 100644
--- a/test/fixtures/mail_handler/ticket_with_invalid_attributes.eml
+++ b/test/fixtures/mail_handler/ticket_with_invalid_attributes.eml
@@ -40,6 +40,7 @@ pulvinar dui, a gravida orci mi eget odio. Nunc a lacus.
Project: onlinestore
Tracker: Feature request
category: Stock management
+assigned to: miscuser9@foo.bar
priority: foo
done ratio: x
start date: some day
diff --git a/test/unit/mail_handler_test.rb b/test/unit/mail_handler_test.rb
index 65b0409bb..9fe35b62d 100644
--- a/test/unit/mail_handler_test.rb
+++ b/test/unit/mail_handler_test.rb
@@ -25,6 +25,7 @@ class MailHandlerTest < ActiveSupport::TestCase
:roles,
:members,
:member_roles,
+ :users,
:issues,
:issue_statuses,
:workflows,
@@ -234,6 +235,7 @@ class MailHandlerTest < ActiveSupport::TestCase
assert issue.is_a?(Issue)
assert !issue.new_record?
issue.reload
+ assert_nil issue.assigned_to
assert_nil issue.start_date
assert_nil issue.due_date
assert_equal 0, issue.done_ratio