Merged r11525 from trunk (#11498).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/2.3-stable@11581 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
58af20746b
commit
974863e8f4
|
@ -38,7 +38,8 @@ class MailHandler < ActionMailer::Base
|
||||||
# Status overridable by default
|
# Status overridable by default
|
||||||
@@handler_options[:allow_override] << 'status' unless @@handler_options[:issue].has_key?(:status)
|
@@handler_options[:allow_override] << 'status' unless @@handler_options[:issue].has_key?(:status)
|
||||||
|
|
||||||
@@handler_options[:no_permission_check] = (@@handler_options[:no_permission_check].to_s == '1' ? true : false)
|
@@handler_options[:no_account_notice] = (@@handler_options[:no_account_notice].to_s == '1')
|
||||||
|
@@handler_options[:no_permission_check] = (@@handler_options[:no_permission_check].to_s == '1')
|
||||||
|
|
||||||
email.force_encoding('ASCII-8BIT') if email.respond_to?(:force_encoding)
|
email.force_encoding('ASCII-8BIT') if email.respond_to?(:force_encoding)
|
||||||
super(email)
|
super(email)
|
||||||
|
@ -98,7 +99,9 @@ class MailHandler < ActionMailer::Base
|
||||||
logger.info "MailHandler: [#{@user.login}] account created"
|
logger.info "MailHandler: [#{@user.login}] account created"
|
||||||
end
|
end
|
||||||
add_user_to_group(@@handler_options[:default_group])
|
add_user_to_group(@@handler_options[:default_group])
|
||||||
Mailer.account_information(@user, @user.password).deliver
|
unless @@handler_options[:no_account_notice]
|
||||||
|
Mailer.account_information(@user, @user.password).deliver
|
||||||
|
end
|
||||||
else
|
else
|
||||||
if logger && logger.error
|
if logger && logger.error
|
||||||
logger.error "MailHandler: could not create account for [#{sender_email}]"
|
logger.error "MailHandler: could not create account for [#{sender_email}]"
|
||||||
|
|
|
@ -23,9 +23,10 @@ module Net
|
||||||
end
|
end
|
||||||
|
|
||||||
class RedmineMailHandler
|
class RedmineMailHandler
|
||||||
VERSION = '0.2.2'
|
VERSION = '0.2.3'
|
||||||
|
|
||||||
attr_accessor :verbose, :issue_attributes, :allow_override, :unknown_user, :default_group, :no_permission_check, :url, :key, :no_check_certificate
|
attr_accessor :verbose, :issue_attributes, :allow_override, :unknown_user, :default_group, :no_permission_check,
|
||||||
|
:url, :key, :no_check_certificate, :no_account_notice
|
||||||
|
|
||||||
def initialize
|
def initialize
|
||||||
self.issue_attributes = {}
|
self.issue_attributes = {}
|
||||||
|
@ -59,6 +60,8 @@ class RedmineMailHandler
|
||||||
"* create: create a user account") {|v| self.unknown_user = v}
|
"* create: create a user account") {|v| self.unknown_user = v}
|
||||||
opts.on("--default-group GROUP", "add created user to GROUP (none by default)",
|
opts.on("--default-group GROUP", "add created user to GROUP (none by default)",
|
||||||
"GROUP can be a comma separated list of groups") { |v| self.default_group = v}
|
"GROUP can be a comma separated list of groups") { |v| self.default_group = v}
|
||||||
|
opts.on("--no-account-notice", "don't send account information to the newly",
|
||||||
|
"created user") { |v| self.no_account_notice = '1'}
|
||||||
opts.separator("")
|
opts.separator("")
|
||||||
opts.separator("Issue attributes control options:")
|
opts.separator("Issue attributes control options:")
|
||||||
opts.on("-p", "--project PROJECT", "identifier of the target project") {|v| self.issue_attributes['project'] = v}
|
opts.on("-p", "--project PROJECT", "identifier of the target project") {|v| self.issue_attributes['project'] = v}
|
||||||
|
@ -100,6 +103,7 @@ class RedmineMailHandler
|
||||||
'allow_override' => allow_override,
|
'allow_override' => allow_override,
|
||||||
'unknown_user' => unknown_user,
|
'unknown_user' => unknown_user,
|
||||||
'default_group' => default_group,
|
'default_group' => default_group,
|
||||||
|
'no_account_notice' => no_account_notice,
|
||||||
'no_permission_check' => no_permission_check}
|
'no_permission_check' => no_permission_check}
|
||||||
issue_attributes.each { |attr, value| data["issue[#{attr}]"] = value }
|
issue_attributes.each { |attr, value| data["issue[#{attr}]"] = value }
|
||||||
|
|
||||||
|
|
|
@ -320,6 +320,22 @@ class MailHandlerTest < ActiveSupport::TestCase
|
||||||
assert_same_elements [group1, group2], user.groups
|
assert_same_elements [group1, group2], user.groups
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_created_user_should_not_receive_account_information_with_no_account_info_option
|
||||||
|
assert_difference 'User.count' do
|
||||||
|
submit_email(
|
||||||
|
'ticket_by_unknown_user.eml',
|
||||||
|
:issue => {:project => 'ecookbook'},
|
||||||
|
:unknown_user => 'create',
|
||||||
|
:no_account_notice => '1'
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
# only 1 email for the new issue notification
|
||||||
|
assert_equal 1, ActionMailer::Base.deliveries.size
|
||||||
|
email = ActionMailer::Base.deliveries.first
|
||||||
|
assert_include 'Ticket by unknown user', email.subject
|
||||||
|
end
|
||||||
|
|
||||||
def test_add_issue_without_from_header
|
def test_add_issue_without_from_header
|
||||||
Role.anonymous.add_permission!(:add_issues)
|
Role.anonymous.add_permission!(:add_issues)
|
||||||
assert_equal false, submit_email('ticket_without_from_header.eml')
|
assert_equal false, submit_email('ticket_without_from_header.eml')
|
||||||
|
|
Loading…
Reference in New Issue