@@ -38,7 +38,8 class MailHandler < ActionMailer::Base | |||||
38 | # Status overridable by default |
|
38 | # Status overridable by default | |
39 | @@handler_options[:allow_override] << 'status' unless @@handler_options[:issue].has_key?(:status) |
|
39 | @@handler_options[:allow_override] << 'status' unless @@handler_options[:issue].has_key?(:status) | |
40 |
|
40 | |||
41 |
@@handler_options[:no_ |
|
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 | email.force_encoding('ASCII-8BIT') if email.respond_to?(:force_encoding) |
|
44 | email.force_encoding('ASCII-8BIT') if email.respond_to?(:force_encoding) | |
44 | super(email) |
|
45 | super(email) | |
@@ -98,7 +99,9 class MailHandler < ActionMailer::Base | |||||
98 | logger.info "MailHandler: [#{@user.login}] account created" |
|
99 | logger.info "MailHandler: [#{@user.login}] account created" | |
99 | end |
|
100 | end | |
100 | add_user_to_group(@@handler_options[:default_group]) |
|
101 | add_user_to_group(@@handler_options[:default_group]) | |
101 | Mailer.account_information(@user, @user.password).deliver |
|
102 | unless @@handler_options[:no_account_notice] | |
|
103 | Mailer.account_information(@user, @user.password).deliver | |||
|
104 | end | |||
102 | else |
|
105 | else | |
103 | if logger && logger.error |
|
106 | if logger && logger.error | |
104 | logger.error "MailHandler: could not create account for [#{sender_email}]" |
|
107 | logger.error "MailHandler: could not create account for [#{sender_email}]" |
@@ -39,9 +39,10 module Net | |||||
39 | end |
|
39 | end | |
40 |
|
40 | |||
41 | class RedmineMailHandler |
|
41 | class RedmineMailHandler | |
42 |
VERSION = '0.2. |
|
42 | VERSION = '0.2.3' | |
43 |
|
43 | |||
44 |
attr_accessor :verbose, :issue_attributes, :allow_override, :unknown_user, :default_group, :no_permission_check, |
|
44 | attr_accessor :verbose, :issue_attributes, :allow_override, :unknown_user, :default_group, :no_permission_check, | |
|
45 | :url, :key, :no_check_certificate, :no_account_notice | |||
45 |
|
46 | |||
46 | def initialize |
|
47 | def initialize | |
47 | self.issue_attributes = {} |
|
48 | self.issue_attributes = {} | |
@@ -75,6 +76,8 class RedmineMailHandler | |||||
75 | "* create: create a user account") {|v| self.unknown_user = v} |
|
76 | "* create: create a user account") {|v| self.unknown_user = v} | |
76 | opts.on("--default-group GROUP", "add created user to GROUP (none by default)", |
|
77 | opts.on("--default-group GROUP", "add created user to GROUP (none by default)", | |
77 | "GROUP can be a comma separated list of groups") { |v| self.default_group = v} |
|
78 | "GROUP can be a comma separated list of groups") { |v| self.default_group = v} | |
|
79 | opts.on("--no-account-notice", "don't send account information to the newly", | |||
|
80 | "created user") { |v| self.no_account_notice = '1'} | |||
78 | opts.separator("") |
|
81 | opts.separator("") | |
79 | opts.separator("Issue attributes control options:") |
|
82 | opts.separator("Issue attributes control options:") | |
80 | opts.on("-p", "--project PROJECT", "identifier of the target project") {|v| self.issue_attributes['project'] = v} |
|
83 | opts.on("-p", "--project PROJECT", "identifier of the target project") {|v| self.issue_attributes['project'] = v} | |
@@ -116,6 +119,7 class RedmineMailHandler | |||||
116 | 'allow_override' => allow_override, |
|
119 | 'allow_override' => allow_override, | |
117 | 'unknown_user' => unknown_user, |
|
120 | 'unknown_user' => unknown_user, | |
118 | 'default_group' => default_group, |
|
121 | 'default_group' => default_group, | |
|
122 | 'no_account_notice' => no_account_notice, | |||
119 | 'no_permission_check' => no_permission_check} |
|
123 | 'no_permission_check' => no_permission_check} | |
120 | issue_attributes.each { |attr, value| data["issue[#{attr}]"] = value } |
|
124 | issue_attributes.each { |attr, value| data["issue[#{attr}]"] = value } | |
121 |
|
125 |
@@ -320,6 +320,22 class MailHandlerTest < ActiveSupport::TestCase | |||||
320 | assert_same_elements [group1, group2], user.groups |
|
320 | assert_same_elements [group1, group2], user.groups | |
321 | end |
|
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 | def test_add_issue_without_from_header |
|
339 | def test_add_issue_without_from_header | |
324 | Role.anonymous.add_permission!(:add_issues) |
|
340 | Role.anonymous.add_permission!(:add_issues) | |
325 | assert_equal false, submit_email('ticket_without_from_header.eml') |
|
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