]> source.dussan.org Git - redmine.git/commitdiff
Merged r13104 (#16655).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 24 May 2014 16:30:41 +0000 (16:30 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 24 May 2014 16:30:41 +0000 (16:30 +0000)
git-svn-id: http://svn.redmine.org/redmine/branches/2.5-stable@13156 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/mail_handler.rb
test/unit/mail_handler_test.rb

index da2c5c4e5a27369b56eb25987188d7a0bb8b2525..702befcd75cd8219128a2f25b0ecf2c7e2160d10 100644 (file)
@@ -190,6 +190,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)
index 8b2f6e2986aedd776453614ddf9f194626dfb14a..86f286e76a02d11da0f7eb288af90488a29bf158 100644 (file)
@@ -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