diff --git a/app/models/import.rb b/app/models/import.rb index b6336ae042..102bcde737 100644 --- a/app/models/import.rb +++ b/app/models/import.rb @@ -33,6 +33,7 @@ class Import < ActiveRecord::Base '%Y-%m-%d', '%d/%m/%Y', '%m/%d/%Y', + '%Y/%m/%d', '%d.%m.%Y', '%d-%m-%Y' ] diff --git a/test/fixtures/files/import_dates_with_other_format.csv b/test/fixtures/files/import_dates_with_other_format.csv new file mode 100644 index 0000000000..58c0a4491d --- /dev/null +++ b/test/fixtures/files/import_dates_with_other_format.csv @@ -0,0 +1,2 @@ +subject;start +Valid dates;2015/07/10; \ No newline at end of file diff --git a/test/unit/issue_import_test.rb b/test/unit/issue_import_test.rb index eb0cef0067..cea992db2e 100644 --- a/test/unit/issue_import_test.rb +++ b/test/unit/issue_import_test.rb @@ -215,6 +215,15 @@ class IssueImportTest < ActiveSupport::TestCase assert_equal Date.parse('2015-07-10'), issue.start_date assert_equal Date.parse('2015-08-12'), issue.due_date assert_equal '2015-07-14', issue.custom_field_value(field) + + # Tests using other date formats + import = generate_import_with_mapping('import_dates_with_other_format.csv') + import.settings.merge!('date_format' => Import::DATE_FORMATS[3]) + import.mapping.merge!('tracker' => 'value:1', 'subject' => '0', 'start_date' => '1') + import.save! + + issue = new_record(Issue) { import.run } + assert_equal Date.parse('2015-07-10'), issue.start_date end def test_date_format_should_default_to_user_language