diff options
author | Etienne Massip <etienne.massip@gmail.com> | 2012-06-16 21:45:47 +0000 |
---|---|---|
committer | Etienne Massip <etienne.massip@gmail.com> | 2012-06-16 21:45:47 +0000 |
commit | dbdc9b9da7564eafd9d74aa9d664642193d9791d (patch) | |
tree | feae1f5b26478f3a8fe847c6515e48ba1ae552ff /test/unit/lib | |
parent | 2c07b478bb1e2954c44d9def732202a8edea9837 (diff) | |
download | redmine-dbdc9b9da7564eafd9d74aa9d664642193d9791d.tar.gz redmine-dbdc9b9da7564eafd9d74aa9d664642193d9791d.zip |
Display dates using user's locale if available (#2190).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@9838 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/unit/lib')
-rw-r--r-- | test/unit/lib/redmine/i18n_test.rb | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/test/unit/lib/redmine/i18n_test.rb b/test/unit/lib/redmine/i18n_test.rb index 0b7ee20f0..85d9a1312 100644 --- a/test/unit/lib/redmine/i18n_test.rb +++ b/test/unit/lib/redmine/i18n_test.rb @@ -22,7 +22,7 @@ class Redmine::I18nTest < ActiveSupport::TestCase include ActionView::Helpers::NumberHelper def setup - @hook_module = Redmine::Hook + User.current.language = nil end def test_date_format_default @@ -39,6 +39,16 @@ class Redmine::I18nTest < ActiveSupport::TestCase assert_equal today.strftime('%d %m %Y'), format_date(today) end + def test_date_format_default_with_user_locale + set_language_if_valid 'es' + today = now = Time.parse('2011-02-20 14:00:00') + Setting.date_format = '%d %B %Y' + User.current.language = 'fr' + assert_equal "20 f\u00E9vrier 2011", format_date(today) + User.current.language = nil + assert_equal '20 Febrero 2011', format_date(today) + end + def test_date_and_time_for_each_language Setting.date_format = '' valid_languages.each do |lang| @@ -99,6 +109,22 @@ class Redmine::I18nTest < ActiveSupport::TestCase end end + def test_time_format_default_with_user_locale + set_language_if_valid 'en' + User.current.language = 'fr' + now = Time.parse('2011-02-20 15:45:22') + with_settings :time_format => '' do + with_settings :date_format => '' do + assert_equal '20/02/2011 15:45', format_time(now) + assert_equal '15:45', format_time(now, false) + end + with_settings :date_format => '%Y-%m-%d' do + assert_equal '2011-02-20 15:45', format_time(now) + assert_equal '15:45', format_time(now, false) + end + end + end + def test_time_format set_language_if_valid 'en' now = Time.now |