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

use hard wired date calculation for NWD specs

ulferts63888b2ad3ca
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 b7c5eb27a8a..6f8189f023e 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', beginning_of_week: :locale, js: true do
+describe 'Team planner error handling', 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 c0f3271208f..03b1a0c0de6 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', beginning_of_week: :locale, js: true do
+describe 'Working Days', js: true do
create_shared_association_defaults_for_work_package_factory
shared_let(:week_days) { week_with_saturday_and_sunday_as_weekend }
@@ -199,7 +199,7 @@ describe 'Working Days', beginning_of_week: :locale, js: true do
fill_in 'name', with: 'My holiday'
end
- date1 = Time.zone.today.next_week.next_occurring(:monday)
+ date1 = NonWorkingDay.maximum(:date).next_week(:monday).next_occurring(:monday)
datepicker.set_date date1
page.within('[data-qa-selector="op-datepicker-modal"]') do
@@ -215,7 +215,7 @@ describe 'Working Days', beginning_of_week: :locale, js: true do
fill_in 'name', with: 'Another important day'
end
- date2 = Time.zone.today.next_week.next_occurring(:tuesday)
+ date2 = NonWorkingDay.maximum(:date).next_week(:monday).next_occurring(:tuesday)
datepicker.set_date date2
page.within('[data-qa-selector="op-datepicker-modal"]') do
diff --git a/spec/support/i18n.rb b/spec/support/i18n.rb
deleted file mode 100644
index 7225401eb22..00000000000
--- a/spec/support/i18n.rb
+++ /dev/null
@@ -1,31 +0,0 @@
-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 |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
- 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