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: on `beginning_of_week: :locale`, set `Date.beginning_of_week`

Sebastian Fiedlschusterfd439484da73
diff --git a/modules/team_planner/spec/features/team_planner_error_handling_spec.rb b/modules/team_planner/spec/features/team_planner_error_handling_spec.rb
index 6f8189f023e..b7c5eb27a8a 100644
--- a/modules/team_planner/spec/features/team_planner_error_handling_spec.rb
+++ b/modules/team_planner/spec/features/team_planner_error_handling_spec.rb
@@ -29,7 +29,7 @@
require 'spec_helper'
require_relative './shared_context'
-describe 'Team planner error handling', js: true do
+describe 'Team planner error handling', beginning_of_week: :locale, js: true do
include_context 'with team planner full access'
let!(:work_package) do
diff --git a/spec/features/admin/working_days_spec.rb b/spec/features/admin/working_days_spec.rb
index 8d7090c958e..284096b3f76 100644
--- a/spec/features/admin/working_days_spec.rb
+++ b/spec/features/admin/working_days_spec.rb
@@ -28,7 +28,7 @@
require 'spec_helper'
-describe 'Working Days', js: true do
+describe 'Working Days', beginning_of_week: :locale, js: true do
create_shared_association_defaults_for_work_package_factory
shared_let(:week_days) { week_with_saturday_and_sunday_as_weekend }
diff --git a/spec/support/i18n.rb b/spec/support/i18n.rb
index fe75f9728d9..7225401eb22 100644
--- a/spec/support/i18n.rb
+++ b/spec/support/i18n.rb
@@ -1,11 +1,24 @@
RSpec.configure do |config|
-
# Change `Date.beginning_of_week` in the context of the specs
# according to the current locale.
#
+ # Usage:
+ #
+ # context "with Date.beginning_of_week based on I18n.locale", beginning_of_week: :locale
+ # context "with Date.beginning_of_week set on :sunday", beginning_of_week: :sunday
+ #
# See also: https://github.com/opf/openproject/pull/12066
#
- config.append_before do
+ config.append_before do |example|
+ beginning_of_week = example.metadata[:beginning_of_week]
+ if beginning_of_week == :locale
+ set_beginning_of_week_based_on_locale
+ elsif beginning_of_week.present? and beginning_of_week.is_a? Symbol
+ Date.beginning_of_week = beginning_of_week
+ end
+ end
+
+ def set_beginning_of_week_based_on_locale
case I18n.locale
when :en
Date.beginning_of_week = :sunday