]> source.dussan.org Git - redmine.git/commitdiff
Ability to define a default assigned_to when receiving emails (#23020).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 18 Jun 2016 07:07:41 +0000 (07:07 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 18 Jun 2016 07:07:41 +0000 (07:07 +0000)
git-svn-id: http://svn.redmine.org/redmine/trunk@15547 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/mail_handler.rb
extra/mail_handler/rdm-mailhandler.rb
lib/tasks/email.rake
test/unit/mail_handler_test.rb

index a619f115dd2d5211f380ad95dad7dde7abe8b7c9..28841310ec4b6a04fa47c1adf1bc00817fb037d3 100644 (file)
@@ -62,7 +62,7 @@ class MailHandler < ActionMailer::Base
   # Use when receiving emails with rake tasks
   def self.extract_options_from_env(env)
     options = {:issue => {}}
-    %w(project status tracker category priority fixed_version).each do |option|
+    %w(project status tracker category priority assigned_to fixed_version).each do |option|
       options[:issue][option.to_sym] = env[option] if env[option]
     end
     %w(allow_override unknown_user no_permission_check no_account_notice default_group project_from_subaddress).each do |option|
index 7784f48dd87a7ba20f63db4a99071c10bd6b1e79..4a74df15a5070f1795aa85b923e1e01d8019dc7a 100644 (file)
@@ -93,6 +93,7 @@ class RedmineMailHandler
       opts.on("-t", "--tracker TRACKER",      "name of the target tracker") {|v| self.issue_attributes['tracker'] = v}
       opts.on(      "--category CATEGORY",    "name of the target category") {|v| self.issue_attributes['category'] = v}
       opts.on(      "--priority PRIORITY",    "name of the target priority") {|v| self.issue_attributes['priority'] = v}
+      opts.on(      "--assigned-to ASSIGNEE", "assignee (username or group name)") {|v| self.issue_attributes['assigned_to'] = v}
       opts.on(      "--fixed-version VERSION","name of the target version") {|v| self.issue_attributes['fixed_version'] = v}
       opts.on(      "--private",              "create new issues as private") {|v| self.issue_attributes['is_private'] = '1'}
       opts.on("-o", "--allow-override ATTRS", "allow email content to set attributes values",
index fe6fb92abac969c0b5ef38a5883f74d8ca72606a..1b62abb23e2eabad2f1235aab76c81718e92b291 100644 (file)
@@ -64,6 +64,7 @@ Issue attributes control options:
   tracker=TRACKER          name of the target tracker
   category=CATEGORY        name of the target category
   priority=PRIORITY        name of the target priority
+  assigned_to=ASSIGNEE     assignee (username or group name)
   fixed_version=VERSION    name of the target version
   private                  create new issues as private
   allow_override=ATTRS     allow email content to set attributes values
index f08f2a6cdfd0cf23560de0faf2abaf2808240c2e..07d579a5dec0c3c5a25a787a1c22089ba2c735bd 100644 (file)
@@ -140,6 +140,17 @@ class MailHandlerTest < ActiveSupport::TestCase
     assert_equal 'Alpha', issue.reload.fixed_version.name
   end
 
+  def test_add_issue_with_default_assigned_to
+    # This email contains: 'Project: onlinestore'
+    issue = submit_email(
+              'ticket_on_given_project.eml',
+              :issue => {:assigned_to => 'jsmith'}
+            )
+    assert issue.is_a?(Issue)
+    assert !issue.new_record?
+    assert_equal 'jsmith', issue.reload.assigned_to.login
+  end
+
   def test_add_issue_with_status_override
     # This email contains: 'Project: onlinestore' and 'Status: Resolved'
     issue = submit_email('ticket_on_given_project.eml', :allow_override => ['status'])