Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

rewrites #format_date legacy specs

ulfertsc73fc1b77265
diff --git a/spec/lib/redmine/i18n_spec.rb b/spec/lib/redmine/i18n_spec.rb
index b0f012b860c..bdece981734 100644
--- a/spec/lib/redmine/i18n_spec.rb
+++ b/spec/lib/redmine/i18n_spec.rb
@@ -190,5 +190,21 @@ module OpenProject
end
end
end
+
+ describe '#format_date' do
+ context 'without a date_format setting', with_settings: { date_format: '' } do
+ it 'uses the locale formate' do
+ expect(format_date(Date.today))
+ .to eql I18n.l(Date.today)
+ end
+ end
+
+ context 'with a date_format setting', with_settings: { date_format: '%d %m %Y' } do
+ it 'adheres to the format' do
+ expect(format_date(Date.today))
+ .to eql Date.today.strftime('%d %m %Y')
+ end
+ end
+ end
end
end
diff --git a/spec_legacy/unit/lib/redmine/i18n_spec.rb b/spec_legacy/unit/lib/redmine/i18n_spec.rb
index c6a1fbb0dc2..55c333d032c 100644
--- a/spec_legacy/unit/lib/redmine/i18n_spec.rb
+++ b/spec_legacy/unit/lib/redmine/i18n_spec.rb
@@ -36,20 +36,6 @@ describe Redmine::I18n do
@hook_module = Redmine::Hook
end
- it 'should date format default' do
- set_language_if_valid 'en'
- today = Date.today
- Setting.date_format = ''
- assert_equal I18n.l(today), format_date(today)
- end
-
- it 'should date format' do
- set_language_if_valid 'en'
- today = Date.today
- Setting.date_format = '%d %m %Y'
- assert_equal today.strftime('%d %m %Y'), format_date(today)
- end
-
it 'should date and time for each language' do
Setting.date_format = ''
valid_languages.each do |lang|