##// END OF EJS Templates
Use the default project when receiving an email with an invalid project keyword (#14491)....
Jean-Philippe Lang -
r11837:1502da5726cf
parent child
Show More
@@ -28,6 +28,7 class MailHandler < ActionMailer::Base
28 @@handler_options = options.dup
28 @@handler_options = options.dup
29
29
30 @@handler_options[:issue] ||= {}
30 @@handler_options[:issue] ||= {}
31 @@handler_options[:issue].symbolize_keys!
31
32
32 if @@handler_options[:allow_override].is_a?(String)
33 if @@handler_options[:allow_override].is_a?(String)
33 @@handler_options[:allow_override] = @@handler_options[:allow_override].split(',').collect(&:strip)
34 @@handler_options[:allow_override] = @@handler_options[:allow_override].split(',').collect(&:strip)
@@ -333,6 +334,13 class MailHandler < ActionMailer::Base
333 # * parse the email To field
334 # * parse the email To field
334 # * specific project (eg. Setting.mail_handler_target_project)
335 # * specific project (eg. Setting.mail_handler_target_project)
335 target = Project.find_by_identifier(get_keyword(:project))
336 target = Project.find_by_identifier(get_keyword(:project))
337 if target.nil?
338 # Invalid project keyword, use the project specified as the default one
339 default_project = @@handler_options[:issue][:project]
340 if default_project.present?
341 target = Project.find_by_identifier(default_project)
342 end
343 end
336 raise MissingInformation.new('Unable to determine target project') if target.nil?
344 raise MissingInformation.new('Unable to determine target project') if target.nil?
337 target
345 target
338 end
346 end
@@ -370,6 +370,15 class MailHandlerTest < ActiveSupport::TestCase
370 assert issue.description.include?('Lorem ipsum dolor sit amet, consectetuer adipiscing elit.')
370 assert issue.description.include?('Lorem ipsum dolor sit amet, consectetuer adipiscing elit.')
371 end
371 end
372
372
373 def test_add_issue_with_invalid_project_should_be_assigned_to_default_project
374 issue = submit_email('ticket_on_given_project.eml', :issue => {:project => 'ecookbook'}, :allow_override => 'project') do |email|
375 email.gsub!(/^Project:.+$/, 'Project: invalid')
376 end
377 assert issue.is_a?(Issue)
378 assert !issue.new_record?
379 assert_equal 'ecookbook', issue.project.identifier
380 end
381
373 def test_add_issue_with_localized_attributes
382 def test_add_issue_with_localized_attributes
374 User.find_by_mail('jsmith@somenet.foo').update_attribute 'language', 'fr'
383 User.find_by_mail('jsmith@somenet.foo').update_attribute 'language', 'fr'
375 issue = submit_email(
384 issue = submit_email(
General Comments 0
You need to be logged in to leave comments. Login now