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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
feature spec for project phase rescheduling on configuration change
ulfertsf51085da80f5
diff --git a/app/models/project.rb b/app/models/project.rbindex 8a52e52cb85..e774b995fa2 100644--- a/app/models/project.rb+++ b/app/models/project.rb@@ -139,6 +139,7 @@ class Project < ApplicationRecorddatetime: :created_atregister_journal_formatted_fields "active", formatter_key: :active_status+ register_journal_formatted_fields "cause", formatter_key: :causeregister_journal_formatted_fields "templated", formatter_key: :templateregister_journal_formatted_fields "identifier", "name", formatter_key: :plaintextregister_journal_formatted_fields "status_explanation", "description", formatter_key: :diffdiff --git a/spec/factories/project_phase_factory.rb b/spec/factories/project_phase_factory.rbindex 0fa67d9c2bf..e08e1c7c8fc 100644--- a/spec/factories/project_phase_factory.rb+++ b/spec/factories/project_phase_factory.rb@@ -36,7 +36,12 @@ FactoryBot.define dostart_date { Date.current - 2.days }finish_date { Date.current + 2.days }- duration { date_range_set? ? finish_date - start_date + 1 : nil }+ duration do+ next 0 unless date_range_set?++ working_days = Setting.find_by(name: :working_days).value.map(&:to_i)+ (start_date..finish_date).count { |d| working_days.include?(d.cwday) }+ endtrait :skip_validate doto_create { |instance| instance.save(validate: false) }diff --git a/spec/features/admin/working_days_spec.rb b/spec/features/admin/working_days_spec.rbindex 6f555d61401..0486b0a6a94 100644--- a/spec/features/admin/working_days_spec.rb+++ b/spec/features/admin/working_days_spec.rb@@ -34,6 +34,31 @@ RSpec.describe "Working Days", :js docreate_shared_association_defaults_for_work_package_factoryshared_let(:week_days) { week_with_saturday_and_sunday_as_weekend }++ shared_let(:project) { create(:project) }+ shared_let(:phase_definition1) { create(:project_phase_definition) }+ shared_let(:phase_definition2) { create(:project_phase_definition) }+ shared_let(:phase1_start_date) { Date.new(2026, 10, 5) } # A Monday+ shared_let(:phase1_end_date) { Date.new(2026, 10, 8) } # A Thursday+ shared_let(:phase2_start_date) { Date.new(2026, 10, 9) } # A Friday+ shared_let(:phase2_end_date) { Date.new(2026, 10, 13) } # A Tuesday++ # Create consecutive phases with fixed dates+ shared_let(:phase1) do+ create(:project_phase,+ project:,+ definition: phase_definition1,+ start_date: phase1_start_date,+ finish_date: phase1_end_date)+ end++ shared_let(:phase2) do+ create(:project_phase,+ project:,+ definition: phase_definition2,+ start_date: phase2_start_date,+ finish_date: phase2_end_date)+ endshared_let(:admin) { create(:admin) }let_work_packages(<<~TABLE)@@ -45,6 +70,7 @@ RSpec.describe "Working Days", :js dolet(:dialog) { Components::ConfirmationDialog.new }let(:datepicker) { Components::DatepickerModal.new }+ let(:project_activity_page) { Pages::Projects::Activity.new(project) }current_user { admin }@@ -179,6 +205,53 @@ RSpec.describe "Working Days", :js doexpect_flash(type: :error,message: "The previous changes to the working days configuration have not been applied yet.")end++ it "updates project phase date ranges when working days change" do+ # Project phases layout before changes+ #+ # | name | MTWTFSSmtwtfssmt | duration |+ # | Planning | XXXX | 4 days |+ # | Implementation | X..XX | 3 days |+ expect(working_days_setting).to eq([1, 2, 3, 4, 5])++ # Change working days configuration+ uncheck "Monday"+ uncheck "Friday"++ click_on "Apply changes"++ perform_enqueued_jobs do+ dialog.confirm+ end++ expect_flash(message: "Successful update.")++ # Expected phase layout after changes+ #+ # | name | MTWTFSSmtwtfssmt | duration |+ # | Planning | XXX....X | 4 days |+ # | Implementation | XX....X | 3 days |+ phase1.reload+ phase2.reload++ # Verify phases have been adjusted for the new working days+ # Monday is now non-working so the start date should have moved to Tuesday+ expect(phase1.start_date).to eq(Date.new(2026, 10, 6)) # Tuesday+ # The end date should be adjusted to maintain the same duration in working days+ expect(phase1.finish_date).to eq(Date.new(2026, 10, 13)) # Tuesday++ # Second phase should also be adjusted and remain consecutive with phase1+ expect(phase2.start_date).to eq(Date.new(2026, 10, 14)) # Wednesday+ expect(phase2.finish_date).to eq(Date.new(2026, 10, 20)) # Tuesday++ # Check the journal entries for the phases+ project_activity_page.visit!++ project_activity_page.show_details++ project_activity_page+ .expect_activity("Dates changed by changes to working days (Monday is now non-working, Friday is now non-working)")+ endenddescribe "non-working days" do