summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2015-08-14 15:52:04 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2015-08-14 15:52:04 +0000
commit67ea285dea5185fa11b351a3fa8507c6fb92e030 (patch)
tree9f7c041b4fee22c4e5ad9c8d9e1a399bdfcb5c2a
parent722eaed7216270d8e89f50c92abb1cfaf9bf1503 (diff)
downloadredmine-67ea285dea5185fa11b351a3fa8507c6fb92e030.tar.gz
redmine-67ea285dea5185fa11b351a3fa8507c6fb92e030.zip
Set default date format based on user locale (#950).
git-svn-id: http://svn.redmine.org/redmine/trunk@14496 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r--app/models/import.rb6
-rw-r--r--test/unit/issue_import_test.rb10
2 files changed, 15 insertions, 1 deletions
diff --git a/app/models/import.rb b/app/models/import.rb
index df29d1788..589967428 100644
--- a/app/models/import.rb
+++ b/app/models/import.rb
@@ -59,10 +59,14 @@ class Import < ActiveRecord::Base
wrapper = '"'
encoding = lu(user, :general_csv_encoding)
+ date_format = lu(user, "date.formats.default", :default => "foo")
+ date_format = DATE_FORMATS.first unless DATE_FORMATS.include?(date_format)
+
self.settings.merge!(
'separator' => separator,
'wrapper' => wrapper,
- 'encoding' => encoding
+ 'encoding' => encoding,
+ 'date_format' => date_format
)
end
diff --git a/test/unit/issue_import_test.rb b/test/unit/issue_import_test.rb
index aee1af441..7d0a7b9e1 100644
--- a/test/unit/issue_import_test.rb
+++ b/test/unit/issue_import_test.rb
@@ -92,6 +92,16 @@ class IssueImportTest < ActiveSupport::TestCase
assert_equal '2015-07-14', issue.custom_field_value(field)
end
+ def test_date_format_should_default_to_user_language
+ user = User.generate!(:language => 'fr')
+ import = Import.new
+ import.user = user
+ assert_nil import.settings['date_format']
+
+ import.set_default_settings
+ assert_equal '%d/%m/%Y', import.settings['date_format']
+ end
+
def test_run_should_remove_the_file
import = generate_import_with_mapping
file_path = import.filepath