summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2014-04-26 06:57:09 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2014-04-26 06:57:09 +0000
commit43c9d69bf251a033b2c6d6562e56e91a1442d3da (patch)
tree4b8893b10ff085d52ae4b3ba0135497ad8959a43
parent709211cb9cc110babfb56e43491ea0dafe9d69b0 (diff)
downloadredmine-43c9d69bf251a033b2c6d6562e56e91a1442d3da.tar.gz
redmine-43c9d69bf251a033b2c6d6562e56e91a1442d3da.zip
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
-rw-r--r--app/models/mail_handler.rb1
-rw-r--r--test/unit/mail_handler_test.rb36
2 files changed, 24 insertions, 13 deletions
diff --git a/app/models/mail_handler.rb b/app/models/mail_handler.rb
index e2dba0e41..1b4600536 100644
--- a/app/models/mail_handler.rb
+++ b/app/models/mail_handler.rb
@@ -198,6 +198,7 @@ class MailHandler < ActionMailer::Base
issue.subject = '(no subject)'
end
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_watchers(issue)
diff --git a/test/unit/mail_handler_test.rb b/test/unit/mail_handler_test.rb
index 1e0e6847c..96d16d845 100644
--- a/test/unit/mail_handler_test.rb
+++ b/test/unit/mail_handler_test.rb
@@ -205,6 +205,14 @@ class MailHandlerTest < ActiveSupport::TestCase
assert_equal user, issue.assigned_to
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
issue = submit_email('ticket_with_cc.eml', :issue => {:project => 'ecookbook'})
assert issue.is_a?(Issue)
@@ -357,19 +365,21 @@ class MailHandlerTest < ActiveSupport::TestCase
end
def test_add_issue_with_invalid_attributes
- issue = submit_email(
- 'ticket_with_invalid_attributes.eml',
- :allow_override => 'tracker,category,priority'
- )
- assert issue.is_a?(Issue)
- assert !issue.new_record?
- issue.reload
- assert_nil issue.assigned_to
- assert_nil issue.start_date
- assert_nil issue.due_date
- assert_equal 0, issue.done_ratio
- assert_equal 'Normal', issue.priority.to_s
- assert issue.description.include?('Lorem ipsum dolor sit amet, consectetuer adipiscing elit.')
+ with_settings :default_issue_start_date_to_creation_date => '0' do
+ issue = submit_email(
+ 'ticket_with_invalid_attributes.eml',
+ :allow_override => 'tracker,category,priority'
+ )
+ assert issue.is_a?(Issue)
+ assert !issue.new_record?
+ issue.reload
+ assert_nil issue.assigned_to
+ assert_nil issue.start_date
+ assert_nil issue.due_date
+ assert_equal 0, issue.done_ratio
+ assert_equal 'Normal', issue.priority.to_s
+ assert issue.description.include?('Lorem ipsum dolor sit amet, consectetuer adipiscing elit.')
+ end
end
def test_add_issue_with_invalid_project_should_be_assigned_to_default_project