##// END OF EJS Templates
Adds private issue option to receiving emails (#8424)....
Jean-Philippe Lang -
r13880:d640f7b249b9
parent child
Show More
@@ -69,6 +69,9 class MailHandler < ActionMailer::Base
69 69 %w(allow_override unknown_user no_permission_check no_account_notice default_group).each do |option|
70 70 options[option.to_sym] = env[option] if env[option]
71 71 end
72 if env['private']
73 options[:issue][:is_private] = '1'
74 end
72 75 options
73 76 end
74 77
@@ -205,6 +208,7 class MailHandler < ActionMailer::Base
205 208 end
206 209 issue.description = cleaned_up_text_body
207 210 issue.start_date ||= Date.today if Setting.default_issue_start_date_to_creation_date?
211 issue.is_private = (handler_options[:issue][:is_private] == '1')
208 212
209 213 # add To and Cc as watchers before saving so the watchers can reply to Redmine
210 214 add_watchers(issue)
@@ -87,6 +87,7 class RedmineMailHandler
87 87 opts.on("-t", "--tracker TRACKER", "name of the target tracker") {|v| self.issue_attributes['tracker'] = v}
88 88 opts.on( "--category CATEGORY", "name of the target category") {|v| self.issue_attributes['category'] = v}
89 89 opts.on( "--priority PRIORITY", "name of the target priority") {|v| self.issue_attributes['priority'] = v}
90 opts.on( "--private", "create new issues as private") {|v| self.issue_attributes['is_private'] = '1'}
90 91 opts.on("-o", "--allow-override ATTRS", "allow email content to override attributes",
91 92 "specified by previous options",
92 93 "ATTRS is a comma separated list of attributes") {|v| self.allow_override = v}
@@ -89,6 +89,7 Issue attributes control options:
89 89 tracker=TRACKER name of the target tracker
90 90 category=CATEGORY name of the target category
91 91 priority=PRIORITY name of the target priority
92 private create new issues as private
92 93 allow_override=ATTRS allow email content to override attributes
93 94 specified by previous options
94 95 ATTRS is a comma separated list of attributes
@@ -38,6 +38,21 class MailHandlerControllerTest < ActionController::TestCase
38 38 assert_response 201
39 39 end
40 40
41 def test_should_create_issue_with_options
42 # Enable API and set a key
43 Setting.mail_handler_api_enabled = 1
44 Setting.mail_handler_api_key = 'secret'
45
46 assert_difference 'Issue.count' do
47 post :index, :key => 'secret',
48 :email => IO.read(File.join(FIXTURES_PATH, 'ticket_on_given_project.eml')),
49 :issue => {:is_private => '1'}
50 end
51 assert_response 201
52 issue = Issue.order(:id => :desc).first
53 assert_equal true, issue.is_private
54 end
55
41 56 def test_should_respond_with_422_if_not_created
42 57 Project.find('onlinestore').destroy
43 58
@@ -94,6 +94,13 class MailHandlerTest < ActiveSupport::TestCase
94 94 assert_equal IssueStatus.find_by_name("Resolved"), issue.status
95 95 end
96 96
97 def test_add_issue_should_accept_is_private_attribute
98 issue = submit_email('ticket_on_given_project.eml', :issue => {:is_private => '1'})
99 assert issue.is_a?(Issue)
100 assert !issue.new_record?
101 assert_equal true, issue.reload.is_private
102 end
103
97 104 def test_add_issue_with_attributes_override
98 105 issue = submit_email(
99 106 'ticket_with_attributes.eml',
General Comments 0
You need to be logged in to leave comments. Login now