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

specs: set `Date.beginning_of_week` according to locale

Sebastian Fiedlschuster61fd493a84ef
diff --git a/spec/support/i18n.rb b/spec/support/i18n.rb
new file mode 100644
index 00000000000..fe75f9728d9
--- /dev/null
+++ b/spec/support/i18n.rb
@@ -0,0 +1,18 @@
+RSpec.configure do |config|
+
+ # Change `Date.beginning_of_week` in the context of the specs
+ # according to the current locale.
+ #
+ # See also: https://github.com/opf/openproject/pull/12066
+ #
+ config.append_before do
+ case I18n.locale
+ when :en
+ Date.beginning_of_week = :sunday
+ when :de, :fr
+ Date.beginning_of_week = :monday
+ else
+ Rails.logger.warn "First day of week not defined for locale #{I18n.locale} in spec/support/i18n.rb."
+ end
+ end
+end