Set default start date on issues created by email if default_issue_start_date_to_creation_date is set (#16655).

git-svn-id: http://svn.redmine.org/redmine/trunk@13104 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2014-04-26 06:57:09 +00:00
parent 709211cb9c
commit 43c9d69bf2
2 changed files with 24 additions and 13 deletions

View File

@ -198,6 +198,7 @@ class MailHandler < ActionMailer::Base
issue.subject = '(no subject)' issue.subject = '(no subject)'
end end
issue.description = cleaned_up_text_body issue.description = cleaned_up_text_body
issue.start_date ||= Date.today if Setting.default_issue_start_date_to_creation_date?
# add To and Cc as watchers before saving so the watchers can reply to Redmine # add To and Cc as watchers before saving so the watchers can reply to Redmine
add_watchers(issue) add_watchers(issue)

View File

@ -205,6 +205,14 @@ class MailHandlerTest < ActiveSupport::TestCase
assert_equal user, issue.assigned_to assert_equal user, issue.assigned_to
end end
def test_add_issue_should_set_default_start_date
with_settings :default_issue_start_date_to_creation_date => '1' do
issue = submit_email('ticket_with_cc.eml', :issue => {:project => 'ecookbook'})
assert issue.is_a?(Issue)
assert_equal Date.today, issue.start_date
end
end
def test_add_issue_with_cc def test_add_issue_with_cc
issue = submit_email('ticket_with_cc.eml', :issue => {:project => 'ecookbook'}) issue = submit_email('ticket_with_cc.eml', :issue => {:project => 'ecookbook'})
assert issue.is_a?(Issue) assert issue.is_a?(Issue)
@ -357,19 +365,21 @@ class MailHandlerTest < ActiveSupport::TestCase
end end
def test_add_issue_with_invalid_attributes def test_add_issue_with_invalid_attributes
issue = submit_email( with_settings :default_issue_start_date_to_creation_date => '0' do
'ticket_with_invalid_attributes.eml', issue = submit_email(
:allow_override => 'tracker,category,priority' 'ticket_with_invalid_attributes.eml',
) :allow_override => 'tracker,category,priority'
assert issue.is_a?(Issue) )
assert !issue.new_record? assert issue.is_a?(Issue)
issue.reload assert !issue.new_record?
assert_nil issue.assigned_to issue.reload
assert_nil issue.start_date assert_nil issue.assigned_to
assert_nil issue.due_date assert_nil issue.start_date
assert_equal 0, issue.done_ratio assert_nil issue.due_date
assert_equal 'Normal', issue.priority.to_s assert_equal 0, issue.done_ratio
assert issue.description.include?('Lorem ipsum dolor sit amet, consectetuer adipiscing elit.') assert_equal 'Normal', issue.priority.to_s
assert issue.description.include?('Lorem ipsum dolor sit amet, consectetuer adipiscing elit.')
end
end end
def test_add_issue_with_invalid_project_should_be_assigned_to_default_project def test_add_issue_with_invalid_project_should_be_assigned_to_default_project