##// END OF EJS Templates
Merged r11525 from trunk (#11498)....
Jean-Philippe Lang -
r11351:974863e8f419
parent child
Show More
@@ -38,7 +38,8 class MailHandler < ActionMailer::Base
38 38 # Status overridable by default
39 39 @@handler_options[:allow_override] << 'status' unless @@handler_options[:issue].has_key?(:status)
40 40
41 @@handler_options[:no_permission_check] = (@@handler_options[:no_permission_check].to_s == '1' ? true : false)
41 @@handler_options[:no_account_notice] = (@@handler_options[:no_account_notice].to_s == '1')
42 @@handler_options[:no_permission_check] = (@@handler_options[:no_permission_check].to_s == '1')
42 43
43 44 email.force_encoding('ASCII-8BIT') if email.respond_to?(:force_encoding)
44 45 super(email)
@@ -98,7 +99,9 class MailHandler < ActionMailer::Base
98 99 logger.info "MailHandler: [#{@user.login}] account created"
99 100 end
100 101 add_user_to_group(@@handler_options[:default_group])
102 unless @@handler_options[:no_account_notice]
101 103 Mailer.account_information(@user, @user.password).deliver
104 end
102 105 else
103 106 if logger && logger.error
104 107 logger.error "MailHandler: could not create account for [#{sender_email}]"
@@ -23,9 +23,10 module Net
23 23 end
24 24
25 25 class RedmineMailHandler
26 VERSION = '0.2.2'
26 VERSION = '0.2.3'
27 27
28 attr_accessor :verbose, :issue_attributes, :allow_override, :unknown_user, :default_group, :no_permission_check, :url, :key, :no_check_certificate
28 attr_accessor :verbose, :issue_attributes, :allow_override, :unknown_user, :default_group, :no_permission_check,
29 :url, :key, :no_check_certificate, :no_account_notice
29 30
30 31 def initialize
31 32 self.issue_attributes = {}
@@ -59,6 +60,8 class RedmineMailHandler
59 60 "* create: create a user account") {|v| self.unknown_user = v}
60 61 opts.on("--default-group GROUP", "add created user to GROUP (none by default)",
61 62 "GROUP can be a comma separated list of groups") { |v| self.default_group = v}
63 opts.on("--no-account-notice", "don't send account information to the newly",
64 "created user") { |v| self.no_account_notice = '1'}
62 65 opts.separator("")
63 66 opts.separator("Issue attributes control options:")
64 67 opts.on("-p", "--project PROJECT", "identifier of the target project") {|v| self.issue_attributes['project'] = v}
@@ -100,6 +103,7 class RedmineMailHandler
100 103 'allow_override' => allow_override,
101 104 'unknown_user' => unknown_user,
102 105 'default_group' => default_group,
106 'no_account_notice' => no_account_notice,
103 107 'no_permission_check' => no_permission_check}
104 108 issue_attributes.each { |attr, value| data["issue[#{attr}]"] = value }
105 109
@@ -320,6 +320,22 class MailHandlerTest < ActiveSupport::TestCase
320 320 assert_same_elements [group1, group2], user.groups
321 321 end
322 322
323 def test_created_user_should_not_receive_account_information_with_no_account_info_option
324 assert_difference 'User.count' do
325 submit_email(
326 'ticket_by_unknown_user.eml',
327 :issue => {:project => 'ecookbook'},
328 :unknown_user => 'create',
329 :no_account_notice => '1'
330 )
331 end
332
333 # only 1 email for the new issue notification
334 assert_equal 1, ActionMailer::Base.deliveries.size
335 email = ActionMailer::Base.deliveries.first
336 assert_include 'Ticket by unknown user', email.subject
337 end
338
323 339 def test_add_issue_without_from_header
324 340 Role.anonymous.add_permission!(:add_issues)
325 341 assert_equal false, submit_email('ticket_without_from_header.eml')
General Comments 0
You need to be logged in to leave comments. Login now