]> source.dussan.org Git - redmine.git/commitdiff
MailHandler: ignore assignee if invalid.
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 14 Nov 2010 13:48:01 +0000 (13:48 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 14 Nov 2010 13:48:01 +0000 (13:48 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4404 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/mail_handler.rb
test/fixtures/mail_handler/ticket_with_invalid_attributes.eml
test/unit/mail_handler_test.rb

index a5cf21f979216c4cac7ae99da4a042c77bd95522..00010059f829a8aa1ee33416ca95947d19dea5c3 100644 (file)
@@ -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}'),
index 3b39fb5516de71501bf37cda36e6ff251cac219c..4506078d772ef98262e6fc75a8f265e5d24a37d0 100644 (file)
@@ -40,6 +40,7 @@ pulvinar dui, a gravida orci mi eget odio. Nunc a lacus.
 Project: onlinestore\r
 Tracker: Feature request\r
 category: Stock management\r
+assigned to: miscuser9@foo.bar\r
 priority: foo\r
 done ratio: x\r
 start date: some day \r
index 65b0409bb55b7e7a931287b4415b2f51d85d5b80..9fe35b62dfae35ea3028b8a6f8f03b1985ac8a8a 100644 (file)
@@ -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