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

[59539] Make work packages manually scheduled by default

Christophe Bliard2d7288d317b3
diff --git a/app/models/work_packages/scopes/for_scheduling.rb b/app/models/work_packages/scopes/for_scheduling.rb
index 63310f8419c..9cf41621a0b 100644
--- a/app/models/work_packages/scopes/for_scheduling.rb
+++ b/app/models/work_packages/scopes/for_scheduling.rb
@@ -51,6 +51,11 @@ module WorkPackages::Scopes
# statement works, is that a work package is considered to be scheduled
# manually if *all* of its descendants are scheduled manually.
#
+ # One notable exception is if one of the manually scheduled children is
+ # the origin work package of the rescheduling. In this case, the parent is
+ # also subject to reschedule as the origin work package dates may have
+ # changed.
+ #
# For example in case of the hierarchy:
# A and B <- hierarchy (C is parent of both A and B) - C <- hierarchy - D
# * A and B are work packages
@@ -157,21 +162,25 @@ module WorkPackages::Scopes
def scheduling_paths_sql(work_packages)
values = work_packages.map do |wp|
::OpenProject::SqlSanitization
- .sanitize "(:id, false, false)",
+ .sanitize "(:id, false, false, true)",
id: wp.id
end.join(", ")
<<~SQL.squish
- to_schedule (id, manually) AS (
+ to_schedule (id, manually, hierarchy_up, origin) AS (
- SELECT * FROM (VALUES#{values}) AS t(id, manually, hierarchy_up)
+ SELECT * FROM (VALUES#{values}) AS t(id, manually, hierarchy_up, origin)
UNION
SELECT
relations.from_id id,
- (related_work_packages.schedule_manually OR COALESCE(descendants.manually, false)) manually,
- relations.hierarchy_up
+ (related_work_packages.schedule_manually
+ OR (COALESCE(descendants.manually, false)
+ AND NOT (to_schedule.origin AND relations.hierarchy_up))
+ ) manually,
+ relations.hierarchy_up,
+ false origin
FROM
to_schedule
JOIN LATERAL
@@ -196,7 +205,7 @@ module WorkPackages::Scopes
FROM
work_package_hierarchies
WHERE
- NOT to_schedule.manually
+ (NOT to_schedule.manually OR to_schedule.origin)
AND ((work_package_hierarchies.ancestor_id = to_schedule.id AND NOT to_schedule.hierarchy_up AND work_package_hierarchies.generations = 1)
OR (work_package_hierarchies.descendant_id = to_schedule.id AND work_package_hierarchies.generations > 0))
) relations ON relations.to_id = to_schedule.id
diff --git a/app/services/work_packages/update_ancestors_service.rb b/app/services/work_packages/update_ancestors_service.rb
index 877833bd858..24aa3c4fb0f 100644
--- a/app/services/work_packages/update_ancestors_service.rb
+++ b/app/services/work_packages/update_ancestors_service.rb
@@ -209,9 +209,7 @@ class WorkPackages::UpdateAncestorsService
end
def ignore_non_working_days_of_descendants(ancestor, loader)
- children = loader
- .children_of(ancestor)
- .reject(&:schedule_manually)
+ children = loader.children_of(ancestor)
if children.any?
children.any?(&:ignore_non_working_days)
diff --git a/db/migrate/20241120095318_update_scheduling_mode_and_lags.rb b/db/migrate/20241120095318_update_scheduling_mode_and_lags.rb
index bd3d0ae9453..1023745ccf7 100644
--- a/db/migrate/20241120095318_update_scheduling_mode_and_lags.rb
+++ b/db/migrate/20241120095318_update_scheduling_mode_and_lags.rb
@@ -1,5 +1,9 @@
class UpdateSchedulingModeAndLags < ActiveRecord::Migration[7.1]
def up
+ change_column_default :work_packages, :schedule_manually, from: false, to: true
+ execute "UPDATE work_packages SET schedule_manually = false WHERE schedule_manually IS NULL"
+ change_column_null :work_packages, :schedule_manually, false
+
migration_job = WorkPackages::AutomaticMode::MigrateValuesJob
if Rails.env.development?
migration_job.perform_now
@@ -7,4 +11,10 @@ class UpdateSchedulingModeAndLags < ActiveRecord::Migration[7.1]
migration_job.perform_later
end
end
+
+ def down
+ change_column_default :work_packages, :schedule_manually, from: true, to: false
+ # Keep the not-null constraint when rolling back
+ change_column_null :work_packages, :schedule_manually, false
+ end
end
diff --git a/modules/team_planner/spec/features/team_planner_remove_event_spec.rb b/modules/team_planner/spec/features/team_planner_remove_event_spec.rb
index 359a6fc5783..53238cceeb1 100644
--- a/modules/team_planner/spec/features/team_planner_remove_event_spec.rb
+++ b/modules/team_planner/spec/features/team_planner_remove_event_spec.rb
@@ -61,6 +61,7 @@ RSpec.describe "Team planner remove event",
project:,
subject: "Parent work package",
assigned_to: other_user,
+ schedule_manually: false, # because parent of child_wp
start_date: Time.zone.today.beginning_of_week.next_occurring(:wednesday),
due_date: Time.zone.today.beginning_of_week.next_occurring(:thursday),
derived_start_date: Time.zone.today.beginning_of_week.next_occurring(:wednesday),
diff --git a/modules/team_planner/spec/features/team_planner_user_interaction_spec.rb b/modules/team_planner/spec/features/team_planner_user_interaction_spec.rb
index 416f2800db9..9a855d80e44 100644
--- a/modules/team_planner/spec/features/team_planner_user_interaction_spec.rb
+++ b/modules/team_planner/spec/features/team_planner_user_interaction_spec.rb
@@ -29,7 +29,7 @@
require "spec_helper"
require_relative "shared_context"
-RSpec.describe "Team planner drag&dop and resizing",
+RSpec.describe "Team planner drag&drop and resizing",
:js,
:selenium,
with_ee: %i[team_planner_view],
@@ -46,6 +46,7 @@ RSpec.describe "Team planner drag&dop and resizing",
create(:work_package,
project:,
assigned_to: other_user,
+ schedule_manually: false, # because parent of second_wp
start_date: Time.zone.today.beginning_of_week.next_occurring(:tuesday),
due_date: Time.zone.today.beginning_of_week.next_occurring(:thursday))
end
diff --git a/spec/controllers/work_packages/bulk_controller_spec.rb b/spec/controllers/work_packages/bulk_controller_spec.rb
index 716c4568b68..9803995f735 100644
--- a/spec/controllers/work_packages/bulk_controller_spec.rb
+++ b/spec/controllers/work_packages/bulk_controller_spec.rb
@@ -565,7 +565,7 @@ RSpec.describe WorkPackages::BulkController, with_settings: { journal_aggregatio
end
let(:new_parent) do
- create(:work_package, project: project1)
+ create(:work_package, schedule_manually: false, project: project1)
end
before do
diff --git a/spec/features/admin/working_days_spec.rb b/spec/features/admin/working_days_spec.rb
index 3327d455d7d..4790fad97ab 100644
--- a/spec/features/admin/working_days_spec.rb
+++ b/spec/features/admin/working_days_spec.rb
@@ -34,12 +34,12 @@ RSpec.describe "Working Days", :js do
shared_let(:week_days) { week_with_saturday_and_sunday_as_weekend }
shared_let(:admin) { create(:admin) }
- let_schedule(<<~CHART)
- days | MTWTFSSmtwtfss |
- earliest_work_package | XXXXX |
- second_work_package | XX..XX |
- follower | XXX | follows earliest_work_package, follows second_work_package
- CHART
+ let_work_packages(<<~TABLE)
+ subject | MTWTFSSmtwtfss | scheduling mode | properties
+ earliest_work_package | XXXXX | manual |
+ second_work_package | XX..XX | manual |
+ follower | XXX | automatic | follows earliest_work_package, follows second_work_package
+ TABLE
let(:dialog) { Components::ConfirmationDialog.new }
let(:datepicker) { Components::DatepickerModal.new }
@@ -83,12 +83,12 @@ RSpec.describe "Working Days", :js do
expect(working_days_setting).to eq([1, 2, 3, 4, 5])
- expect_schedule(WorkPackage.all, <<~CHART)
- days | MTWTFSSmtwtfss |
+ expect_work_packages(WorkPackage.all, <<~TABLE)
+ subject | MTWTFSSmtwtfss |
earliest_work_package | XXXXX |
second_work_package | XX..XX |
follower | XXX |
- CHART
+ TABLE
end
it "updates the values and saves the settings" do
@@ -114,12 +114,12 @@ RSpec.describe "Working Days", :js do
expect(working_days_setting).to eq([2, 3, 4])
- expect_schedule(WorkPackage.all, <<~CHART)
- days | MTWTFSSmtwtfssmtwt |
+ expect_work_packages(WorkPackage.all, <<~TABLE)
+ subject | MTWTFSSmtwtfssmtwt |
earliest_work_package | XXX....XX |
second_work_package | X....XXX |
follower | XXX |
- CHART
+ TABLE
# The updated work packages will have a journal entry informing about the change
wp_page = Pages::FullWorkPackage.new(earliest_work_package)
@@ -155,12 +155,12 @@ RSpec.describe "Working Days", :js do
expect(page).to have_unchecked_field "Sunday"
expect(working_days_setting).to eq([1, 2, 3, 4, 5])
- expect_schedule(WorkPackage.all, <<~CHART)
- days | MTWTFSSmtwtfss |
+ expect_work_packages(WorkPackage.all, <<~TABLE)
+ subject | MTWTFSSmtwtfss |
earliest_work_package | XXXXX |
second_work_package | XX..XX |
follower | XXX |
- CHART
+ TABLE
end
it "shows an error when a previous change to the working days configuration isn't processed yet" do
diff --git a/spec/features/work_packages/datepicker/datepicker_follows_relation_spec.rb b/spec/features/work_packages/datepicker/datepicker_follows_relation_spec.rb
index 75bb0ebe55b..f2227df0c49 100644
--- a/spec/features/work_packages/datepicker/datepicker_follows_relation_spec.rb
+++ b/spec/features/work_packages/datepicker/datepicker_follows_relation_spec.rb
@@ -79,7 +79,7 @@ RSpec.describe "Datepicker logic on follow relationships", :js, with_settings: {
end
context "if the follower is a task" do
- let!(:follower) { create(:work_package, type:, project:) }
+ let!(:follower) { create(:work_package, type:, project:, schedule_manually: false) }
let!(:relation) { create(:follows_relation, from: follower, to: predecessor) }
let(:date_field) { work_packages_page.edit_field(:combinedDate) }
@@ -87,7 +87,7 @@ RSpec.describe "Datepicker logic on follow relationships", :js, with_settings: {
end
context "if the follower is a milestone" do
- let!(:follower) { create(:work_package, type: milestone_type, project:) }
+ let!(:follower) { create(:work_package, type: milestone_type, project:, schedule_manually: false) }
let!(:relation) { create(:follows_relation, from: follower, to: predecessor) }
let(:date_field) { work_packages_page.edit_field(:date) }
diff --git a/spec/features/work_packages/datepicker/datepicker_parent_spec.rb b/spec/features/work_packages/datepicker/datepicker_parent_spec.rb
index d39af634704..17aaa6c74d5 100644
--- a/spec/features/work_packages/datepicker/datepicker_parent_spec.rb
+++ b/spec/features/work_packages/datepicker/datepicker_parent_spec.rb
@@ -62,7 +62,7 @@ RSpec.describe "Datepicker logic on parents", :js, with_settings: { date_format:
datepicker.expect_visible
end
- context "with the child having set dates" do
+ context "with the child having set dates and the parent being scheduled automatically" do
let(:child_attributes) do
{
start_date: "2021-02-01",
@@ -71,17 +71,46 @@ RSpec.describe "Datepicker logic on parents", :js, with_settings: { date_format:
}
end
- it "disables the non working days options" do
- datepicker.expect_ignore_non_working_days_disabled
- datepicker.expect_scheduling_mode false
+ context "when the parent is scheduled automatically" do
+ let(:parent_attributes) do
+ {
+ schedule_manually: false
+ }
+ end
- first_monday = Time.zone.today.beginning_of_month.next_occurring(:monday)
- datepicker.expect_disabled(first_monday)
+ it "disables the non-working days options" do
+ datepicker.expect_ignore_non_working_days_disabled
+ datepicker.expect_automatic_scheduling_mode
- datepicker.toggle_scheduling_mode
- datepicker.expect_scheduling_mode true
+ first_monday = Time.zone.today.beginning_of_month.next_occurring(:monday)
+ datepicker.expect_disabled(first_monday)
- datepicker.expect_not_disabled(first_monday)
+ datepicker.toggle_scheduling_mode
+ datepicker.expect_manual_scheduling_mode
+
+ datepicker.expect_not_disabled(first_monday)
+ end
+ end
+
+ context "when the parent is scheduled manually" do
+ let(:parent_attributes) do
+ {
+ schedule_manually: true
+ }
+ end
+
+ it "enables the non-working days options" do
+ datepicker.expect_ignore_non_working_days_enabled
+ datepicker.expect_manual_scheduling_mode
+
+ first_monday = Time.zone.today.beginning_of_month.next_occurring(:monday)
+ datepicker.expect_not_disabled(first_monday)
+
+ datepicker.toggle_scheduling_mode
+ datepicker.expect_automatic_scheduling_mode
+
+ datepicker.expect_disabled(first_monday)
+ end
end
end
end
diff --git a/spec/features/work_packages/scheduling/scheduling_mode_spec.rb b/spec/features/work_packages/scheduling/scheduling_mode_spec.rb
index f0fd65246be..f7f908dc619 100644
--- a/spec/features/work_packages/scheduling/scheduling_mode_spec.rb
+++ b/spec/features/work_packages/scheduling/scheduling_mode_spec.rb
@@ -52,6 +52,7 @@ RSpec.describe "scheduling mode", :js do
let!(:wp) do
create(:work_package,
project:,
+ schedule_manually: false, # because parent of wp_child and follows wp_pre
start_date: Date.parse("2016-01-01"),
due_date: Date.parse("2016-01-05"),
parent: wp_parent)
@@ -59,12 +60,14 @@ RSpec.describe "scheduling mode", :js do
let!(:wp_parent) do
create(:work_package,
project:,
+ schedule_manually: false, # because parent of wp
start_date: Date.parse("2016-01-01"),
due_date: Date.parse("2016-01-05"))
end
let!(:wp_child) do
create(:work_package,
project:,
+ schedule_manually: false, # because needed to have rescheduling working
start_date: Date.parse("2016-01-01"),
due_date: Date.parse("2016-01-05"),
parent: wp)
@@ -80,6 +83,7 @@ RSpec.describe "scheduling mode", :js do
let!(:wp_suc) do
create(:work_package,
project:,
+ schedule_manually: false, # because parent of wp_suc_child and follows wp
start_date: Date.parse("2016-01-06"),
due_date: Date.parse("2016-01-10"),
parent: wp_suc_parent).tap do |suc|
@@ -89,12 +93,14 @@ RSpec.describe "scheduling mode", :js do
let!(:wp_suc_parent) do
create(:work_package,
project:,
+ schedule_manually: false, # because parent of wp_suc
start_date: Date.parse("2016-01-06"),
due_date: Date.parse("2016-01-10"))
end
let!(:wp_suc_child) do
create(:work_package,
project:,
+ schedule_manually: false, # because needed to have rescheduling working
start_date: Date.parse("2016-01-06"),
due_date: Date.parse("2016-01-10"),
parent: wp_suc)
diff --git a/spec/features/work_packages/table/scheduling/manual_scheduling_spec.rb b/spec/features/work_packages/table/scheduling/manual_scheduling_spec.rb
index 20630639355..bc60351eee8 100644
--- a/spec/features/work_packages/table/scheduling/manual_scheduling_spec.rb
+++ b/spec/features/work_packages/table/scheduling/manual_scheduling_spec.rb
@@ -10,7 +10,8 @@ RSpec.describe "Manual scheduling", :js do
create(:work_package,
project:,
type:,
- subject: "Parent")
+ subject: "Parent",
+ schedule_manually: false)
end
let!(:child) do
@@ -117,8 +118,4 @@ RSpec.describe "Manual scheduling", :js do
expect(parent.due_date.iso8601).to eq("2020-07-25")
end
end
-
- context "with a user allowed to view only" do
- let(:role) { create(:project_role, permissions: %i[view_work_packages]) }
- end
end
diff --git a/spec/lib/api/v3/work_packages/schema/specific_work_package_schema_spec.rb b/spec/lib/api/v3/work_packages/schema/specific_work_package_schema_spec.rb
index d429d80fa30..6008b134cf4 100644
--- a/spec/lib/api/v3/work_packages/schema/specific_work_package_schema_spec.rb
+++ b/spec/lib/api/v3/work_packages/schema/specific_work_package_schema_spec.rb
@@ -213,6 +213,10 @@ RSpec.describe API::V3::WorkPackages::Schema::SpecificWorkPackageSchema do
end
context "when scheduled automatically" do
+ before do
+ work_package.schedule_manually = false
+ end
+
it "is not writable" do
expect(subject).not_to be_writable(:start_date)
end
@@ -246,6 +250,10 @@ RSpec.describe API::V3::WorkPackages::Schema::SpecificWorkPackageSchema do
end
context "when scheduled automatically" do
+ before do
+ work_package.schedule_manually = false
+ end
+
it "is not writable" do
expect(subject).not_to be_writable(:due_date)
end
@@ -277,11 +285,18 @@ RSpec.describe API::V3::WorkPackages::Schema::SpecificWorkPackageSchema do
allow(work_package.type).to receive(:is_milestone?).and_return(true)
end
- it "is not writable when the work package is a parent" do
+ it "is not writable when the work package is a parent scheduled automatically" do
allow(work_package).to receive(:leaf?).and_return(false)
+ work_package.schedule_manually = false
expect(subject).not_to be_writable(:date)
end
+ it "is writable when the work package is a parent scheduled manually" do
+ allow(work_package).to receive(:leaf?).and_return(false)
+ work_package.schedule_manually = true
+ expect(subject).to be_writable(:date)
+ end
+
it "is writable when the work package is a leaf" do
allow(work_package).to receive(:leaf?).and_return(true)
expect(subject).to be_writable(:date)
diff --git a/spec/migrations/update_scheduling_mode_and_lags_spec.rb b/spec/migrations/update_scheduling_mode_and_lags_spec.rb
index bab471f2805..8f51d07c450 100644
--- a/spec/migrations/update_scheduling_mode_and_lags_spec.rb
+++ b/spec/migrations/update_scheduling_mode_and_lags_spec.rb
@@ -227,18 +227,18 @@ RSpec.describe UpdateSchedulingModeAndLags, type: :model do
context "for 2 work packages following each other with distant dates" do
shared_let_work_packages(<<~TABLE)
- subject | MTWTFSS | properties
- predecessor 1 | XX |
- follower 1 | XX | follows predecessor 1
+ subject | MTWTFSS | scheduling mode | properties
+ predecessor 1 | XX | manual |
+ follower 1 | XX | automatic | follows predecessor 1
# only start dates
- predecessor 2 | [ |
- follower 2 | [ | follows predecessor 2
+ predecessor 2 | [ | manual |
+ follower 2 | [ | automatic | follows predecessor 2
# only due dates
# if lag is already set, it's overwritten
- predecessor 3 | ] |
- follower 3 | ] | follows predecessor 3 with lag 2
+ predecessor 3 | ] | manual |
+ follower 3 | ] | automatic | follows predecessor 3 with lag 2
TABLE
it "sets a lag to the relation to ensure the distance is kept" do
@@ -270,18 +270,18 @@ RSpec.describe UpdateSchedulingModeAndLags, type: :model do
context "for 2 work packages following each other with missing dates" do
let_work_packages(<<~TABLE)
- subject | MTWTFSS | properties
+ subject | MTWTFSS | scheduling mode | properties
# only predecessor has dates
- predecessor 1 | XX |
- follower 1 | | follows predecessor 1
+ predecessor 1 | XX | manual |
+ follower 1 | | automatic | follows predecessor 1
# only successor has dates
- predecessor 2 | |
- follower 2 | XX | follows predecessor 2
+ predecessor 2 | | manual |
+ follower 2 | XX | automatic | follows predecessor 2
# none have dates
- predecessor 3 | |
- follower 3 | | follows predecessor 3 with lag 2
+ predecessor 3 | | manual |
+ follower 3 | | automatic | follows predecessor 3 with lag 2
TABLE
it "does not change the existing lag" do
@@ -295,11 +295,11 @@ RSpec.describe UpdateSchedulingModeAndLags, type: :model do
context "for a work package following multiple work packages" do
shared_let_work_packages(<<~TABLE)
- subject | MTWTFSS | properties
- predecessor 1 | XX |
- predecessor 2 | XX |
- predecessor 3 | X |
- follower | XX | follows predecessor 1, follows predecessor 2, follows predecessor 3
+ subject | MTWTFSS | scheduling mode | properties
+ predecessor 1 | XX | manual |
+ predecessor 2 | XX | manual |
+ predecessor 3 | X | manual |
+ follower | XX | automatic | follows predecessor 1, follows predecessor 2, follows predecessor 3
TABLE
it "sets a lag only to the closest relation" do
diff --git a/spec/models/relation_spec.rb b/spec/models/relation_spec.rb
index a655ab5adac..08fb58ea76d 100644
--- a/spec/models/relation_spec.rb
+++ b/spec/models/relation_spec.rb
@@ -160,38 +160,44 @@ RSpec.describe Relation do
end
describe "#successor_soonest_start" do
+ let(:monday) { Date.current.next_occurring(:monday) }
+ let(:tuesday) { monday + 1.day }
+ let(:wednesday) { monday + 2.days }
+ let(:thursday) { monday + 3.days }
+ let(:friday) { monday + 4.days }
+
context "with a follows relation" do
- let_schedule(<<~CHART)
- days | MTWTFSS |
+ let_work_packages(<<~TABLE)
+ subject | MTWTFSS | properties
main | ] |
follower | | follows main
- CHART
+ TABLE
it "returns predecessor due_date + 1" do
- relation = schedule.follows_relation(from: "follower", to: "main")
- expect(relation.successor_soonest_start).to eq(schedule.tuesday)
+ relation = _table.relation(successor: "follower")
+ expect(relation.successor_soonest_start).to eq(tuesday)
end
end
context "with a follows relation with predecessor having only start date" do
- let_schedule(<<~CHART)
- days | MTWTFSS |
+ let_work_packages(<<~TABLE)
+ subject | MTWTFSS | properties
main | [ |
follower | | follows main
- CHART
+ TABLE
it "returns predecessor start_date + 1" do
- relation = schedule.follows_relation(from: "follower", to: "main")
- expect(relation.successor_soonest_start).to eq(schedule.tuesday)
+ relation = _table.relation(successor: "follower")
+ expect(relation.successor_soonest_start).to eq(tuesday)
end
end
context "with a non-follows relation" do
- let_schedule(<<~CHART)
- days | MTWTFSS |
+ let_work_packages(<<~TABLE)
+ subject | MTWTFSS |
main | X |
related | |
- CHART
+ TABLE
let(:relation) { create(:relation, from: main, to: related) }
it "returns nil" do
@@ -200,77 +206,77 @@ RSpec.describe Relation do
end
context "with a follows relation with a lag" do
- let_schedule(<<~CHART)
- days | MTWTFSS |
+ let_work_packages(<<~TABLE)
+ subject | MTWTFSS | properties
main | X |
follower_a | | follows main with lag 0
follower_b | | follows main with lag 1
follower_c | | follows main with lag 3
- CHART
+ TABLE
it "returns predecessor due_date + lag + 1" do
- relation_a = schedule.follows_relation(from: "follower_a", to: "main")
- expect(relation_a.successor_soonest_start).to eq(schedule.tuesday)
+ relation_a = _table.relation(successor: "follower_a")
+ expect(relation_a.successor_soonest_start).to eq(tuesday)
- relation_b = schedule.follows_relation(from: "follower_b", to: "main")
- expect(relation_b.successor_soonest_start).to eq(schedule.wednesday)
+ relation_b = _table.relation(successor: "follower_b")
+ expect(relation_b.successor_soonest_start).to eq(wednesday)
- relation_c = schedule.follows_relation(from: "follower_c", to: "main")
- expect(relation_c.successor_soonest_start).to eq(schedule.friday)
+ relation_c = _table.relation(successor: "follower_c")
+ expect(relation_c.successor_soonest_start).to eq(friday)
end
end
context "with a follows relation with a lag and with non-working days in the lag period" do
- let_schedule(<<~CHART)
- days | MTWTFSSmtw |
- main | X░ ░ ░░ ░ |
+ let_work_packages(<<~TABLE)
+ subject | MTWTFSSmtw | properties
+ main | X░ ░ ░░ ░ |
follower_lag0 | ░ ░ ░░ ░ | follows main with lag 0
follower_lag1 | ░ ░ ░░ ░ | follows main with lag 1
follower_lag2 | ░ ░ ░░ ░ | follows main with lag 2
follower_lag3 | ░ ░ ░░ ░ | follows main with lag 3
- CHART
+ TABLE
it "returns a date such as the number of working days between both work package is equal to the lag" do
set_work_week("monday", "wednesday", "friday")
- relation_lag0 = schedule.follows_relation(from: "follower_lag0", to: "main")
- expect(relation_lag0.successor_soonest_start).to eq(schedule.wednesday)
+ relation_lag0 = _table.relation(successor: "follower_lag0")
+ expect(relation_lag0.successor_soonest_start).to eq(wednesday)
- relation_lag1 = schedule.follows_relation(from: "follower_lag1", to: "main")
- expect(relation_lag1.successor_soonest_start).to eq(schedule.friday)
+ relation_lag1 = _table.relation(successor: "follower_lag1")
+ expect(relation_lag1.successor_soonest_start).to eq(friday)
- relation_lag2 = schedule.follows_relation(from: "follower_lag2", to: "main")
- expect(relation_lag2.successor_soonest_start).to eq(schedule.monday + 7.days)
+ relation_lag2 = _table.relation(successor: "follower_lag2")
+ expect(relation_lag2.successor_soonest_start).to eq(monday + 7.days)
- relation_lag3 = schedule.follows_relation(from: "follower_lag3", to: "main")
- expect(relation_lag3.successor_soonest_start).to eq(schedule.wednesday + 7.days)
+ relation_lag3 = _table.relation(successor: "follower_lag3")
+ expect(relation_lag3.successor_soonest_start).to eq(wednesday + 7.days)
end
end
- context "with a follows relation with a lag, non-working days, and follower ignoring non-working days" do
- let_schedule(<<~CHART)
- days | MTWTFSSmtw |
- main | X░ ░ ░░ ░ |
- follower_lag0 | ░ ░ ░░ ░ | follows main with lag 0, working days include weekends
- follower_lag1 | ░ ░ ░░ ░ | follows main with lag 1, working days include weekends
- follower_lag2 | ░ ░ ░░ ░ | follows main with lag 2, working days include weekends
- follower_lag3 | ░ ░ ░░ ░ | follows main with lag 3, working days include weekends
- CHART
+ context "with a follows relation with a lag, non-working days, and followers ignoring non-working days" do
+ let_work_packages(<<~TABLE)
+ subject | MTWTFSSmtw | days counting | properties
+ main | X░ ░ ░░ ░ | working days only |
+ follower_lag0 | ░ ░ ░░ ░ | all days | follows main with lag 0
+ follower_lag1 | ░ ░ ░░ ░ | all days | follows main with lag 1
+ follower_lag2 | ░ ░ ░░ ░ | all days | follows main with lag 2
+ follower_lag3 | ░ ░ ░░ ░ | all days | follows main with lag 3
+ TABLE
it "returns predecessor due_date + lag + 1 (like without non-working days)" do
set_work_week("monday", "wednesday", "friday")
- relation_lag0 = schedule.follows_relation(from: "follower_lag0", to: "main")
- expect(relation_lag0.successor_soonest_start).to eq(schedule.tuesday)
+ relation_lag0 = _table.relation(successor: "follower_lag0")
+ expect(relation_lag0.successor_soonest_start).to eq(tuesday)
- relation_lag1 = schedule.follows_relation(from: "follower_lag1", to: "main")
- expect(relation_lag1.successor_soonest_start).to eq(schedule.wednesday)
+ relation_lag1 = _table.relation(successor: "follower_lag1")
+ expect(relation_lag1.successor_soonest_start).to eq(wednesday)
- relation_lag2 = schedule.follows_relation(from: "follower_lag2", to: "main")
- expect(relation_lag2.successor_soonest_start).to eq(schedule.thursday)
+ relation_lag2 = _table.relation(successor: "follower_lag2")
+ expect(relation_lag2.successor_soonest_start).to eq(thursday)
- relation_lag3 = schedule.follows_relation(from: "follower_lag3", to: "main")
- expect(relation_lag3.successor_soonest_start).to eq(schedule.friday)
+ relation_lag3 = _table.relation(successor: "follower_lag3")
+ expect(relation_lag3.successor_soonest_start).to eq(friday)
end
end
end
diff --git a/spec/models/work_package/work_package_acts_as_journalized_spec.rb b/spec/models/work_package/work_package_acts_as_journalized_spec.rb
index 076ee1464f1..dfcca6fbf18 100644
--- a/spec/models/work_package/work_package_acts_as_journalized_spec.rb
+++ b/spec/models/work_package/work_package_acts_as_journalized_spec.rb
@@ -61,22 +61,22 @@ RSpec.describe WorkPackage do
it "notes the changes to subject" do
expect(work_package.last_journal.details[:subject])
- .to contain_exactly(nil, work_package.subject)
+ .to eq([nil, work_package.subject])
end
it "notes the changes to project" do
expect(work_package.last_journal.details[:project_id])
- .to contain_exactly(nil, work_package.project_id)
+ .to eq([nil, work_package.project_id])
end
it "notes the description" do
expect(work_package.last_journal.details[:description])
- .to contain_exactly(nil, work_package.description)
+ .to eq([nil, work_package.description])
end
it "notes the scheduling mode" do
expect(work_package.last_journal.details[:schedule_manually])
- .to contain_exactly(nil, false)
+ .to eq([nil, true])
end
it "has the timestamp of the work package update time for created_at" do
@@ -174,7 +174,7 @@ RSpec.describe WorkPackage do
work_package.assigned_to = User.current
work_package.responsible = User.current
work_package.parent = parent_work_package
- work_package.schedule_manually = true
+ work_package.schedule_manually = false
work_package.save!
end
@@ -191,68 +191,26 @@ RSpec.describe WorkPackage do
end
end
- shared_examples_for "old value" do
- subject { work_package.last_journal.old_value_for(property) }
-
- it { is_expected.to eq(expected_value) }
- end
-
- shared_examples_for "new value" do
- subject { work_package.last_journal.new_value_for(property) }
-
- it { is_expected.to eq(expected_value) }
- end
-
- describe "journaled value for" do
- describe "description" do
- let(:property) { "description" }
-
- context "for old value" do
- let(:expected_value) { "Description" }
-
- it_behaves_like "old value"
- end
-
- context "for new value" do
- let(:expected_value) { "changed" }
-
- it_behaves_like "new value"
- end
- end
-
- describe "schedule_manually" do
- let(:property) { "schedule_manually" }
-
- context "for old value" do
- let(:expected_value) { false }
-
- it_behaves_like "old value"
- end
-
- context "for new value" do
- let(:expected_value) { true }
-
- it_behaves_like "new value"
- end
- end
-
- describe "duration" do
- let(:property) { "duration" }
-
- context "for old value" do
- let(:expected_value) { 1 }
-
- it_behaves_like "old value"
- end
-
- context "for new value" do
- let(:expected_value) { 8 }
-
- it_behaves_like "new value"
+ shared_examples_for "journaled value for" do |property:, expected_old_value:, expected_new_value:|
+ context "for #{property}", :aggregate_failures do
+ it "tracks the change from old value #{expected_old_value.inspect} to new value #{expected_new_value.inspect}" do
+ journal = work_package.last_journal
+ expect(journal.old_value_for(property)).to eq(expected_old_value)
+ expect(journal.new_value_for(property)).to eq(expected_new_value)
end
end
end
+ include_examples "journaled value for", property: "description",
+ expected_old_value: "Description",
+ expected_new_value: "changed"
+ include_examples "journaled value for", property: "schedule_manually",
+ expected_old_value: true,
+ expected_new_value: false
+ include_examples "journaled value for", property: "duration",
+ expected_old_value: 1,
+ expected_new_value: 8
+
describe "adding journal with a missing journal and an existing journal" do
before do
allow(WorkPackages::UpdateContract).to receive(:new).and_return(NoopContract.new)
diff --git a/spec/models/work_packages/scopes/covering_dates_and_days_of_week_spec.rb b/spec/models/work_packages/scopes/covering_dates_and_days_of_week_spec.rb
index 56db1379d26..2d998f621f9 100644
--- a/spec/models/work_packages/scopes/covering_dates_and_days_of_week_spec.rb
+++ b/spec/models/work_packages/scopes/covering_dates_and_days_of_week_spec.rb
@@ -50,9 +50,9 @@ RSpec.describe WorkPackages::Scopes::CoveringDatesAndDaysOfWeek do
end
it "returns work packages having start date or due date being in the given days of week" do
- schedule =
- create_schedule(<<~CHART)
- days | MTWTFSS |
+ table =
+ create_table(<<~TABLE)
+ subject | MTWTFSS |
covered1 | XX |
covered2 | XX |
covered3 | X |
@@ -62,41 +62,41 @@ RSpec.describe WorkPackages::Scopes::CoveringDatesAndDaysOfWeek do
not_covered2 | X |
not_covered3 | XX |
not_covered4 | |
- CHART
+ TABLE
expect(WorkPackage.covering_dates_and_days_of_week(**day_args[:tuesday]))
.to contain_exactly(
- schedule.work_package("covered1"),
- schedule.work_package("covered2"),
- schedule.work_package("covered3"),
- schedule.work_package("covered4"),
- schedule.work_package("covered5")
+ table.work_package("covered1"),
+ table.work_package("covered2"),
+ table.work_package("covered3"),
+ table.work_package("covered4"),
+ table.work_package("covered5")
)
end
it "returns work packages having days between start date and due date being in the given days of week" do
- schedule =
- create_schedule(<<~CHART)
- days | MTWTFSS |
+ table =
+ create_table(<<~TABLE)
+ subject | MTWTFSS |
covered1 | XXXX |
covered2 | XXX |
not_covered1 | XX |
not_covered2 | X |
- CHART
+ TABLE
expect(WorkPackage.covering_dates_and_days_of_week(**day_args[:tuesday, :wednesday]))
.to contain_exactly(
- schedule.work_package("covered1"),
- schedule.work_package("covered2")
+ table.work_package("covered1"),
+ table.work_package("covered2")
)
end
context "if work package ignores non working days" do
it "does not returns it" do
- create_schedule(<<~CHART)
- days | MTWTFSS |
- not_covered | XXXXXXX | working days include weekends
- CHART
+ create_table(<<~TABLE)
+ subject | MTWTFSS | days counting
+ not_covered | XXXXXXX | all days
+ TABLE
expect(WorkPackage.covering_dates_and_days_of_week(**day_args[:wednesday]))
.to eq([])
@@ -104,47 +104,47 @@ RSpec.describe WorkPackages::Scopes::CoveringDatesAndDaysOfWeek do
end
it "does not return work packages having follows relation covering the given days of week" do
- create_schedule(<<~CHART)
- days | MTWTFSS |
+ create_table(<<~TABLE)
+ subject | MTWTFSS | properties
not_covered1 | X |
follower1 | X | follows not_covered1
not_covered2 | X |
follower2 | X | follows not_covered2
- CHART
+ TABLE
expect(WorkPackage.covering_dates_and_days_of_week(**day_args[:tuesday, :thursday]))
.to eq([])
end
it "does not return work packages having follows relation with lag covering the given days of week" do
- create_schedule(<<~CHART)
- days | MTWTFSS |
+ create_table(<<~TABLE)
+ subject | MTWTFSS | properties
not_covered1 | X |
follower1 | X | follows not_covered1 with lag 3
not_covered2 | X |
follower2 | X | follows not_covered2 with lag 1
- CHART
+ TABLE
expect(WorkPackage.covering_dates_and_days_of_week(**day_args[:tuesday, :thursday]))
.to eq([])
end
it "accepts a single day of week or an array of days" do
- schedule =
- create_schedule(<<~CHART)
- days | MTWTFSS |
+ table =
+ create_table(<<~TABLE)
+ subject | MTWTFSS |
covered | X |
not_covered | X |
- CHART
+ TABLE
single_value = day_args[:tuesday].transform_values { |v| Array(v).first }
expect(WorkPackage.covering_dates_and_days_of_week(**single_value))
- .to eq([schedule.work_package("covered")])
+ .to eq([table.work_package("covered")])
expect(WorkPackage.covering_dates_and_days_of_week(**day_args[:tuesday]))
- .to eq([schedule.work_package("covered")])
+ .to eq([table.work_package("covered")])
expect(WorkPackage.covering_dates_and_days_of_week(**day_args[:tuesday, :wednesday]))
- .to eq([schedule.work_package("covered")])
+ .to eq([table.work_package("covered")])
end
end
diff --git a/spec/models/work_packages/scopes/for_scheduling_spec.rb b/spec/models/work_packages/scopes/for_scheduling_spec.rb
index fb9c4ed6609..ba81c895e30 100644
--- a/spec/models/work_packages/scopes/for_scheduling_spec.rb
+++ b/spec/models/work_packages/scopes/for_scheduling_spec.rb
@@ -31,72 +31,72 @@ require "spec_helper"
RSpec.describe WorkPackages::Scopes::ForScheduling, "allowed scope" do
create_shared_association_defaults_for_work_package_factory
- let(:project) { create(:project) }
- let(:origin) { create(:work_package, project:) }
+ shared_let(:origin) { create(:work_package, subject: "origin") }
+
let(:predecessor) do
- create(:work_package, project:).tap do |pre|
+ create(:work_package, subject: "predecessor").tap do |pre|
create(:follows_relation, from: origin, to: pre)
end
end
let(:parent) do
- create(:work_package, project:).tap do |par|
+ create(:work_package, subject: "parent", schedule_manually: false).tap do |par|
origin.update(parent: par)
end
end
let(:grandparent) do
- create(:work_package, project:).tap do |grand|
+ create(:work_package, subject: "grandparent", schedule_manually: false).tap do |grand|
parent.update(parent: grand)
end
end
let(:successor) do
- create(:work_package, project:).tap do |suc|
+ create(:work_package, subject: "successor", schedule_manually: false).tap do |suc|
create(:follows_relation, from: suc, to: origin)
end
end
let(:successor2) do
- create(:work_package, project:).tap do |suc|
+ create(:work_package, subject: "successor2", schedule_manually: false).tap do |suc|
create(:follows_relation, from: suc, to: origin)
end
end
let(:successor_parent) do
- create(:work_package, project:).tap do |par|
+ create(:work_package, subject: "successor_parent", schedule_manually: false).tap do |par|
successor.update(parent: par)
end
end
let(:successor_child) do
- create(:work_package, project:, parent: successor)
+ create(:work_package, subject: "successor_child", parent: successor)
end
let(:successor_grandchild) do
- create(:work_package, project:, parent: successor_child)
+ create(:work_package, subject: "successor_grandchild", parent: successor_child)
end
let(:successor_child2) do
- create(:work_package, project:, parent: successor)
+ create(:work_package, subject: "successor_child2", parent: successor)
end
let(:successor_successor) do
- create(:work_package, project:).tap do |suc|
+ create(:work_package, subject: "successor_successor", schedule_manually: false).tap do |suc|
create(:follows_relation, from: suc, to: successor)
end
end
let(:parent_successor) do
- create(:work_package, project:).tap do |suc|
+ create(:work_package, subject: "parent_successor", schedule_manually: false).tap do |suc|
create(:follows_relation, from: suc, to: parent)
end
end
let(:parent_successor_parent) do
- create(:work_package, project:).tap do |par|
+ create(:work_package, subject: "parent_successor_parent", schedule_manually: false).tap do |par|
parent_successor.update(parent: par)
end
end
let(:parent_successor_child) do
- create(:work_package, project:, parent: parent_successor)
+ create(:work_package, subject: "parent_successor_child", parent: parent_successor)
end
let(:blocker) do
- create(:work_package, project:).tap do |blo|
+ create(:work_package, subject: "blocker").tap do |blo|
create(:relation, relation_type: "blocks", from: blo, to: origin)
end
end
let(:includer) do
- create(:work_package, project:).tap do |inc|
+ create(:work_package, subject: "includer").tap do |inc|
create(:relation, relation_type: "includes", from: inc, to: origin)
end
end
@@ -115,55 +115,92 @@ RSpec.describe WorkPackages::Scopes::ForScheduling, "allowed scope" do
end
end
- context "for a work package with a predecessor" do
- let!(:existing_work_packages) { [predecessor] }
+ shared_examples "direct relations behaviors" do
+ context "with a predecessor" do
+ let!(:existing_work_packages) { [predecessor] }
- it "is empty" do
- expect(WorkPackage.for_scheduling([origin]))
- .to be_empty
+ it "is empty" do
+ expect(WorkPackage.for_scheduling([origin]))
+ .to be_empty
+ end
end
- end
- context "for a work package with a parent" do
- let!(:existing_work_packages) { [parent] }
+ context "with a parent scheduled automatically" do
+ let!(:existing_work_packages) { [parent] }
- it "consists of the parent" do
- expect(WorkPackage.for_scheduling([origin]))
- .to contain_exactly(parent)
+ it "consists of the parent" do
+ expect(WorkPackage.for_scheduling([origin]))
+ .to contain_exactly(parent)
+ end
end
- end
- context "for a work package with a successor" do
- let!(:existing_work_packages) { [successor] }
+ context "with a parent scheduled manually" do
+ let!(:existing_work_packages) { [parent] }
- it "consists of the successor" do
- expect(WorkPackage.for_scheduling([origin]))
- .to contain_exactly(successor)
+ before do
+ parent.update_column(:schedule_manually, true)
+ end
+
+ it "is empty" do
+ expect(WorkPackage.for_scheduling([origin]))
+ .to be_empty
+ end
end
- end
- context "for a work package with a blocking work package" do
- let!(:existing_work_packages) { [blocker] }
+ context "with a successor" do
+ let!(:existing_work_packages) { [successor] }
- it "is empty" do
- expect(WorkPackage.for_scheduling([origin]))
- .to be_empty
+ it "consists of the successor" do
+ expect(WorkPackage.for_scheduling([origin]))
+ .to contain_exactly(successor)
+ end
+ end
+
+ context "with a blocking work package" do
+ let!(:existing_work_packages) { [blocker] }
+
+ it "is empty" do
+ expect(WorkPackage.for_scheduling([origin]))
+ .to be_empty
+ end
+ end
+
+ context "with an including work package" do
+ let!(:existing_work_packages) { [includer] }
+
+ it "is empty" do
+ expect(WorkPackage.for_scheduling([origin]))
+ .to be_empty
+ end
end
end
- context "for a work package with an including work package" do
- let!(:existing_work_packages) { [includer] }
+ context "for an automatically scheduled work package" do
+ before do
+ origin.update_column(:schedule_manually, false)
+ end
- it "is empty" do
- expect(WorkPackage.for_scheduling([origin]))
- .to be_empty
+ include_examples "direct relations behaviors"
+ end
+
+ context "for a manually scheduled work package" do
+ before do
+ origin.update_column(:schedule_manually, true)
end
+
+ include_examples "direct relations behaviors"
end
context "for a work package with a successor which has parent and child" do
let!(:existing_work_packages) { [successor, successor_child, successor_parent] }
context "with all scheduled automatically" do
+ before do
+ existing_work_packages.each do |wp|
+ wp.update_column(:schedule_manually, false)
+ end
+ end
+
it "consists of the successor, its child and parent" do
expect(WorkPackage.for_scheduling([origin]))
.to contain_exactly(successor, successor_child, successor_parent)
@@ -181,9 +218,10 @@ RSpec.describe WorkPackages::Scopes::ForScheduling, "allowed scope" do
end
end
- context "with the successor's parent scheduled manually" do
+ context "with the successor's parent scheduled manually and child scheduled automatically" do
before do
successor_parent.update_column(:schedule_manually, true)
+ successor_child.update_column(:schedule_manually, false)
end
it "consists of the successor and its child" do
@@ -212,15 +250,22 @@ RSpec.describe WorkPackages::Scopes::ForScheduling, "allowed scope" do
end
context "with all scheduled automatically" do
+ before do
+ existing_work_packages.each do |wp|
+ wp.update_column(:schedule_manually, false)
+ end
+ end
+
it "consists of the successor, its child and parent and the successor successor" do
expect(WorkPackage.for_scheduling([origin]))
.to contain_exactly(successor, successor_child, successor_parent, successor_successor)
end
end
- context "with successor parent scheduled manually" do
+ context "with successor parent scheduled manually and child scheduled automatically" do
before do
successor_parent.update_column(:schedule_manually, true)
+ successor_child.update_column(:schedule_manually, false)
end
it "consists of the successor, its child and successor successor" do
@@ -249,7 +294,13 @@ RSpec.describe WorkPackages::Scopes::ForScheduling, "allowed scope" do
end
context "with all scheduled automatically" do
- it "consists of the successor, its child and parent" do
+ before do
+ existing_work_packages.each do |wp|
+ wp.update_column(:schedule_manually, false)
+ end
+ end
+
+ it "consists of the successor and its parent" do
expect(WorkPackage.for_scheduling([origin]))
.to contain_exactly(successor, successor_parent)
end
@@ -294,24 +345,31 @@ RSpec.describe WorkPackages::Scopes::ForScheduling, "allowed scope" do
let!(:existing_work_packages) { [successor, successor_child, successor_child2, successor_successor] }
context "with all scheduled automatically" do
- it "consists of the successor, its child and the successor˚s successor" do
+ before do
+ existing_work_packages.each do |wp|
+ wp.update_column(:schedule_manually, false)
+ end
+ end
+
+ it "consists of the successor, its child and the successor's successor" do
expect(WorkPackage.for_scheduling([origin]))
.to contain_exactly(successor, successor_child, successor_child2, successor_successor)
end
end
- context "with one of the successor`s children scheduled manually" do
+ context "with one of the successor's children scheduled manually and one automatically" do
before do
successor_child2.update_column(:schedule_manually, true)
+ successor_child.update_column(:schedule_manually, false)
end
- it "consists of the successor, its automatically scheduled child and the successor˚s successor" do
+ it "consists of the successor, its automatically scheduled child and the successor's successor" do
expect(WorkPackage.for_scheduling([origin]))
.to contain_exactly(successor_child, successor, successor_successor)
end
end
- context "with both of the successor`s children scheduled manually" do
+ context "with both of the successor's children scheduled manually" do
before do
successor_child.update_column(:schedule_manually, true)
successor_child2.update_column(:schedule_manually, true)
@@ -343,9 +401,15 @@ RSpec.describe WorkPackages::Scopes::ForScheduling, "allowed scope" do
end
context "for a work package with a parent which has a successor which has parent and child" do
- let!(:existing_work_packages) { [parent, parent_successor, parent_successor_child, parent_successor_parent] }
+ let!(:existing_work_packages) { [parent, parent_successor, parent_successor_parent, parent_successor_child] }
context "with all scheduled automatically" do
+ before do
+ existing_work_packages.each do |wp|
+ wp.update_column(:schedule_manually, false)
+ end
+ end
+
it "consists of the parent, self and the whole parent successor hierarchy" do
expect(WorkPackage.for_scheduling([origin]))
.to contain_exactly(parent, parent_successor, parent_successor_parent, parent_successor_child)
@@ -390,6 +454,12 @@ RSpec.describe WorkPackages::Scopes::ForScheduling, "allowed scope" do
let!(:existing_work_packages) { [successor, successor_successor] }
context "with all scheduled automatically" do
+ before do
+ existing_work_packages.each do |wp|
+ wp.update_column(:schedule_manually, false)
+ end
+ end
+
it "consists of both successors" do
expect(WorkPackage.for_scheduling([origin]))
.to contain_exactly(successor, successor_successor)
@@ -423,15 +493,22 @@ RSpec.describe WorkPackages::Scopes::ForScheduling, "allowed scope" do
let!(:existing_work_packages) { [successor, successor_child, successor_grandchild] }
context "with all scheduled automatically" do
- it "consists of both successors" do
+ before do
+ existing_work_packages.each do |wp|
+ wp.update_column(:schedule_manually, false)
+ end
+ end
+
+ it "consists of the successor and its 2 descendants" do
expect(WorkPackage.for_scheduling([origin]))
.to contain_exactly(successor, successor_child, successor_grandchild)
end
end
- context "with the successor's child scheduled manually" do
+ context "with the successor's child scheduled manually and grand child scheduled automatically" do
before do
successor_child.update_column(:schedule_manually, true)
+ successor_grandchild.update_column(:schedule_manually, false)
end
it "contains the successor" do
@@ -443,42 +520,60 @@ RSpec.describe WorkPackages::Scopes::ForScheduling, "allowed scope" do
context "for a work package with a successor that has a child and two grandchildren" do
let(:successor_grandchild2) do
- create(:work_package, project:, parent: successor_child)
+ create(:work_package, subject: "successor_grandchild2", parent: successor_child)
end
let!(:existing_work_packages) { [successor, successor_child, successor_grandchild, successor_grandchild2] }
context "with all scheduled automatically" do
- it "consists of the successor with its descendants" do
+ before do
+ existing_work_packages.each do |wp|
+ wp.update_column(:schedule_manually, false)
+ end
+ end
+
+ it "consists of the successor with its 3 descendants" do
expect(WorkPackage.for_scheduling([origin]))
.to contain_exactly(successor, successor_child, successor_grandchild, successor_grandchild2)
end
end
- context "with one of the successor's grandchildren scheduled manually" do
+ context "with the successor's child scheduled automatically, " \
+ "one of the successor's grandchildren scheduled manually " \
+ "and the other one scheduled automatically" do
before do
+ successor_child.update_column(:schedule_manually, false)
successor_grandchild.update_column(:schedule_manually, true)
+ successor_grandchild2.update_column(:schedule_manually, false)
end
- it "contains the successor and the non automatically scheduled descendants" do
+ it "contains the successor and the automatically scheduled descendants" do
expect(WorkPackage.for_scheduling([origin]))
.to contain_exactly(successor, successor_child, successor_grandchild2)
end
end
- context "with both of the successor's grandchildren scheduled manually" do
+ context "with the successor's child scheduled automatically " \
+ "and both of the successor's grandchildren scheduled manually" do
before do
+ successor_child.update_column(:schedule_manually, false)
successor_grandchild.update_column(:schedule_manually, true)
successor_grandchild2.update_column(:schedule_manually, true)
end
- it "includes successor" do
+ # It should return an empty array as the successor dates will always be
+ # its manually scheduled child's dates, but it does not cause any harm
+ # to return the successor. It will be processed for rescheduling but
+ # none of its dates will change.
+ #
+ # The SQL is quite complex and I am not sure it's worth fixing.
+ it "consists of the successor" do
expect(WorkPackage.for_scheduling([origin]))
.to contain_exactly(successor)
end
end
- context "with both of the successor's grandchildren and child scheduled manually" do
+ context "with the successor's child and both of the successor's grandchildren scheduled manually" do
before do
successor_child.update_column(:schedule_manually, true)
successor_grandchild.update_column(:schedule_manually, true)
@@ -491,11 +586,20 @@ RSpec.describe WorkPackages::Scopes::ForScheduling, "allowed scope" do
end
end
- context "with the successor's child scheduled manually" do
+ context "with the successor's child scheduled manually " \
+ "and both of the successor's grandchildren scheduled automatically" do
before do
successor_child.update_column(:schedule_manually, true)
+ successor_grandchild.update_column(:schedule_manually, false)
+ successor_grandchild2.update_column(:schedule_manually, false)
end
+ # It should return an empty array as the successor child should be
+ # considered manually scheduled, but it does not cause any harm to
+ # return the successor. It will be processed for rescheduling but none
+ # of its dates will change.
+ #
+ # The SQL is quite complex and I am not sure if it is worth fixing.
it "contains the successor" do
expect(WorkPackage.for_scheduling([origin]))
.to contain_exactly(successor)
@@ -505,17 +609,25 @@ RSpec.describe WorkPackages::Scopes::ForScheduling, "allowed scope" do
context "for a work package with a sibling and a successor that also has a sibling" do
let(:sibling) do
- create(:work_package, project:, parent:)
+ create(:work_package, subject: "sibling", parent:)
end
let(:successor_sibling) do
- create(:work_package, project:, parent: successor_parent)
+ create(:work_package, subject: "successor_sibling", parent: successor_parent)
end
let!(:existing_work_packages) { [parent, sibling, successor, successor_parent, successor_sibling] }
- it "contains the successor and the parents but not the siblings" do
- expect(WorkPackage.for_scheduling([origin]))
- .to contain_exactly(successor, parent, successor_parent)
+ context "with all scheduled automatically" do
+ before do
+ existing_work_packages.each do |wp|
+ wp.update_column(:schedule_manually, false)
+ end
+ end
+
+ it "contains the successor and the parents but not the siblings" do
+ expect(WorkPackage.for_scheduling([origin]))
+ .to contain_exactly(successor, parent, successor_parent)
+ end
end
end
end
diff --git a/spec/requests/api/v3/work_packages/create_resource_spec.rb b/spec/requests/api/v3/work_packages/create_resource_spec.rb
index de07c44385a..94e62e3e359 100644
--- a/spec/requests/api/v3/work_packages/create_resource_spec.rb
+++ b/spec/requests/api/v3/work_packages/create_resource_spec.rb
@@ -187,7 +187,7 @@ RSpec.describe "API v3 Work package resource",
# mind the () for the super call, those are required in rspec's super
let(:parameters) { super().merge(scheduleManually: true) }
- it "sets the scheduling mode to true" do
+ it "sets the scheduling mode to manual (schedule_manually: true)" do
expect(work_package.schedule_manually).to be true
end
end
@@ -195,14 +195,14 @@ RSpec.describe "API v3 Work package resource",
context "with false" do
let(:parameters) { super().merge(scheduleManually: false) }
- it "sets the scheduling mode to false" do
+ it "sets the scheduling mode to automatic (schedule_manually: false)" do
expect(work_package.schedule_manually).to be false
end
end
context "with scheduleManually absent" do
- it "sets the scheduling mode to false (default)" do
- expect(work_package.schedule_manually).to be false
+ it "sets the scheduling mode to manual (schedule_manually: true, the default)" do
+ expect(work_package.schedule_manually).to be true
end
end
end
diff --git a/spec/services/work_packages/create_service_integration_spec.rb b/spec/services/work_packages/create_service_integration_spec.rb
index 7649de1538b..bf4e69b81b2 100644
--- a/spec/services/work_packages/create_service_integration_spec.rb
+++ b/spec/services/work_packages/create_service_integration_spec.rb
@@ -50,6 +50,7 @@ RSpec.describe WorkPackages::CreateService, "integration", type: :model do
let(:parent) do
create(:work_package,
subject: "parent",
+ schedule_manually: false,
project:,
type:)
end
@@ -100,6 +101,7 @@ RSpec.describe WorkPackages::CreateService, "integration", type: :model do
let(:parent) do
create(:work_package,
project:,
+ schedule_manually: false,
start_date: "2024-01-01",
due_date: "2024-01-10",
type: create(:type))
@@ -176,7 +178,7 @@ RSpec.describe WorkPackages::CreateService, "integration", type: :model do
end
it "reports on invalid attachments and sets the new if everything is valid" do
- result = instance.call(**attributes.merge(attachment_ids: [other_users_attachment.id]))
+ result = instance.call(**attributes, attachment_ids: [other_users_attachment.id])
expect(result)
.to be_failure
@@ -191,7 +193,7 @@ RSpec.describe WorkPackages::CreateService, "integration", type: :model do
expect(other_users_attachment.reload.container)
.to be_nil
- result = instance.call(**attributes.merge(attachment_ids: [users_attachment.id]))
+ result = instance.call(**attributes, attachment_ids: [users_attachment.id])
expect(result)
.to be_success
diff --git a/spec/services/work_packages/schedule_dependency/dependency_spec.rb b/spec/services/work_packages/schedule_dependency/dependency_spec.rb
index e62dabfd6ed..25f6b394d1f 100644
--- a/spec/services/work_packages/schedule_dependency/dependency_spec.rb
+++ b/spec/services/work_packages/schedule_dependency/dependency_spec.rb
@@ -34,7 +34,7 @@ require "rails_helper"
# +Dependency+ instance per work package that may need to change due to the
# move. These dependencies are the subjects under test.
RSpec.describe WorkPackages::ScheduleDependency::Dependency do
- subject(:dependency) { dependency_for(work_package_used_in_dependency) }
+ subject(:dependency) { checked_dependency_for(work_package_used_in_dependency) }
create_shared_association_defaults_for_work_package_factory
@@ -43,36 +43,54 @@ RSpec.describe WorkPackages::ScheduleDependency::Dependency do
let(:schedule_dependency) { WorkPackages::ScheduleDependency.new(work_package) }
def dependency_for(work_package)
- dependency = schedule_dependency.dependencies[work_package]
- if dependency.nil?
- available = schedule_dependency.dependencies.keys.map(&:subject).map(&:inspect).to_sentence
- raise ArgumentError, "Unable to find dependency for work package #{work_package.subject.inspect}; " \
- "ScheduleDependency instance has dependencies for work packages #{available}"
- end
+ schedule_dependency.dependencies[work_package]
+ end
- dependency
+ def checked_dependency_for(work_package)
+ dependency_for(work_package).tap do |dependency|
+ if dependency.nil?
+ available = schedule_dependency.dependencies.keys.map { _1.subject.inspect }.to_sentence
+ raise ArgumentError, "Unable to find dependency for work package #{work_package.subject.inspect}; " \
+ "ScheduleDependency instance has dependencies for work packages #{available}"
+ end
+ end
end
def create_predecessor_of(work_package, **attributes)
- create(:work_package, subject: "predecessor of #{work_package.subject}", **attributes).tap do |predecessor|
+ work_package.update_column(:schedule_manually, false)
+ create(:work_package,
+ subject: "predecessor of #{work_package.subject}",
+ schedule_manually: true,
+ **attributes).tap do |predecessor|
create(:follows_relation, from: work_package, to: predecessor)
end
end
def create_follower_of(work_package, **attributes)
- create(:work_package, subject: "follower of #{work_package.subject}", **attributes).tap do |follower|
+ create(:work_package,
+ subject: "follower of #{work_package.subject}",
+ schedule_manually: false,
+ **attributes).tap do |follower|
create(:follows_relation, from: follower, to: work_package)
end
end
def create_parent_of(work_package)
- create(:work_package, subject: "parent of #{work_package.subject}").tap do |parent|
+ create(:work_package,
+ subject: "parent of #{work_package.subject}",
+ schedule_manually: false).tap do |parent|
work_package.update(parent:)
end
end
- def create_child_of(work_package)
- create(:work_package, subject: "child of #{work_package.subject}", parent: work_package)
+ def create_child_of(work_package, **attributes)
+ work_package.update_column(:schedule_manually, false)
+ child_attributes = attributes.reverse_merge(
+ subject: "child of #{work_package.subject}",
+ parent: work_package,
+ schedule_manually: true
+ )
+ create(:work_package, **child_attributes)
end
describe "#dependent_ids" do
@@ -100,9 +118,9 @@ RSpec.describe WorkPackages::ScheduleDependency::Dependency do
end
end
- context "when the work_package has a follower which has a child" do
+ context "when the work_package has a follower which has a child automatically scheduled" do
let!(:follower) { create_follower_of(work_package) }
- let!(:follower_child) { create_child_of(follower) }
+ let!(:follower_child) { create_child_of(follower, schedule_manually: false) }
context "for dependency of the child" do
let(:work_package_used_in_dependency) { follower_child }
@@ -121,6 +139,25 @@ RSpec.describe WorkPackages::ScheduleDependency::Dependency do
end
end
+ context "when the work_package has a follower which has a child manually scheduled" do
+ let!(:follower) { create_follower_of(work_package) }
+ let!(:follower_child) { create_child_of(follower, schedule_manually: true) }
+
+ context "for dependency of the child" do
+ it "has no dependency as its date do not depend on any other work package" do
+ expect(dependency_for(follower_child)).to be_nil
+ end
+ end
+
+ context "for dependency of the follower" do
+ let(:work_package_used_in_dependency) { follower }
+
+ it "has its dates do not depend on the moved work package but on the follower child" do
+ expect(dependency_for(follower)).to be_nil
+ end
+ end
+ end
+
context "when the work_package has multiple parents and followers" do
let!(:first_follower) { create_follower_of(work_package) }
let!(:second_follower) { create_follower_of(work_package) }
@@ -187,10 +224,10 @@ RSpec.describe WorkPackages::ScheduleDependency::Dependency do
end
end
- context "when has a predecessor which has a parent and a child" do
+ context "when has a follower which has a parent and a child automatically scheduled" do
let!(:follower) { create_follower_of(work_package) }
let!(:follower_parent) { create_parent_of(follower) }
- let!(:follower_child) { create_child_of(follower) }
+ let!(:follower_child) { create_child_of(follower, schedule_manually: false) }
context "for dependency of the follower child" do
let(:work_package_used_in_dependency) { follower_child }
@@ -208,6 +245,28 @@ RSpec.describe WorkPackages::ScheduleDependency::Dependency do
end
end
end
+
+ context "when has a follower which has a parent and a child manually scheduled" do
+ let!(:follower) { create_follower_of(work_package) }
+ let!(:follower_parent) { create_parent_of(follower) }
+ let!(:follower_child) { create_child_of(follower, schedule_manually: true) }
+
+ context "for dependency of the follower child" do
+ let(:work_package_used_in_dependency) { follower_child }
+
+ it "has no dependency as its dates do not depend on any other work package (it's manually scheduled)" do
+ expect(dependency_for(follower_child)).to be_nil
+ end
+ end
+
+ context "for dependency of the follower parent" do
+ let(:work_package_used_in_dependency) { follower_parent }
+
+ it "has no dependency as its dates depend on the follower child, and this one is manually scheduled" do
+ expect(dependency_for(follower_parent)).to be_nil
+ end
+ end
+ end
end
end
@@ -215,7 +274,7 @@ RSpec.describe WorkPackages::ScheduleDependency::Dependency do
let(:work_package_used_in_dependency) { work_package }
before do
- work_package.update(due_date: Time.zone.today)
+ work_package.update(due_date: Date.current)
end
context "with a moved predecessor" do
@@ -228,13 +287,13 @@ RSpec.describe WorkPackages::ScheduleDependency::Dependency do
context "with an unmoved predecessor" do
it "returns the soonest start date from the predecessors" do
follower = create_follower_of(work_package)
- unmoved_follower_predecessor = create_predecessor_of(follower, due_date: Time.zone.today + 4.days)
+ unmoved_follower_predecessor = create_predecessor_of(follower, due_date: Date.current + 4.days)
expect(dependency_for(follower).soonest_start_date).to eq(unmoved_follower_predecessor.due_date + 1.day)
end
end
context "with non working days" do
- let!(:tomorrow_we_do_not_work!) { create(:non_working_day, date: Time.zone.tomorrow) }
+ let!(:tomorrow_we_do_not_work!) { create(:non_working_day, date: Date.tomorrow) }
it "returns the soonest start date being a working day" do
follower = create_follower_of(work_package)
diff --git a/spec/services/work_packages/set_schedule_service_spec.rb b/spec/services/work_packages/set_schedule_service_spec.rb
index 29762ad4de2..208c5b28d96 100644
--- a/spec/services/work_packages/set_schedule_service_spec.rb
+++ b/spec/services/work_packages/set_schedule_service_spec.rb
@@ -89,6 +89,7 @@ RSpec.describe WorkPackages::SetScheduleService do
def create_follower(start_date, due_date, predecessors, parent: nil)
work_package = create(:work_package,
subject: "follower of #{predecessors.keys.map(&:subject).to_sentence}",
+ schedule_manually: false,
start_date:,
due_date:,
parent:)
@@ -106,6 +107,7 @@ RSpec.describe WorkPackages::SetScheduleService do
def create_parent(child, start_date: child.start_date, due_date: child.due_date)
create(:work_package,
subject: "parent of #{child.subject}",
+ schedule_manually: false,
start_date:,
due_date:).tap do |parent|
child.parent = parent
@@ -113,12 +115,13 @@ RSpec.describe WorkPackages::SetScheduleService do
end
end
- def create_child(parent, start_date, due_date)
+ def create_child(parent, start_date, due_date, **attributes)
create(:work_package,
subject: "child of #{parent.subject}",
start_date:,
due_date:,
- parent:)
+ parent:,
+ **attributes)
end
subject { instance.call(attributes) }
@@ -453,9 +456,9 @@ RSpec.describe WorkPackages::SetScheduleService do
end
end
- context "with only a parent" do
+ context "with only a parent scheduled automatically" do
let!(:parent_work_package) do
- create(:work_package).tap do |parent|
+ create(:work_package, subject: "parent", schedule_manually: false).tap do |parent|
work_package.parent = parent
work_package.save
end
@@ -475,6 +478,7 @@ RSpec.describe WorkPackages::SetScheduleService do
let!(:parent_work_package) do
create(:work_package,
subject: "parent of #{work_package.subject}",
+ schedule_manually: false,
start_date: Time.zone.today,
due_date: Time.zone.today + 1.day).tap do |parent|
work_package.parent = parent
@@ -591,7 +595,7 @@ RSpec.describe WorkPackages::SetScheduleService do
end
end
- context "with a single successor having a child" do
+ context "with a single successor having a child scheduled manually" do
let(:child_start_date) { follower1_start_date }
let(:child_due_date) { follower1_due_date }
@@ -602,6 +606,32 @@ RSpec.describe WorkPackages::SetScheduleService do
child_work_package]
end
+ context "when moving forward" do
+ before do
+ work_package.due_date = Time.zone.today + 5.days
+ end
+
+ # does not reschedules the child, so the follower keeps its dates
+ it_behaves_like "does not reschedule"
+ end
+ end
+
+ context "with a single successor having a child scheduled automatically" do
+ let(:child_start_date) { follower1_start_date }
+ let(:child_due_date) { follower1_due_date }
+
+ let(:child_work_package) do
+ create_child(following_work_package1,
+ child_start_date,
+ child_due_date,
+ schedule_manually: false)
+ end
+
+ let!(:following) do
+ [following_work_package1,
+ child_work_package]
+ end
+
context "when moving forward" do
before do
work_package.due_date = Time.zone.today + 5.days
@@ -616,7 +646,7 @@ RSpec.describe WorkPackages::SetScheduleService do
end
end
- context "with a single successor having two children" do
+ context "with a single successor having two children scheduled automatically" do
let(:follower1_start_date) { work_package_due_date + 1.day }
let(:follower1_due_date) { work_package_due_date + 10.days }
let(:child1_start_date) { follower1_start_date }
@@ -624,8 +654,18 @@ RSpec.describe WorkPackages::SetScheduleService do
let(:child2_start_date) { follower1_start_date + 8.days }
let(:child2_due_date) { follower1_due_date }
- let(:child1_work_package) { create_child(following_work_package1, child1_start_date, child1_due_date) }
- let(:child2_work_package) { create_child(following_work_package1, child2_start_date, child2_due_date) }
+ let(:child1_work_package) do
+ create_child(following_work_package1,
+ child1_start_date,
+ child1_due_date,
+ schedule_manually: false)
+ end
+ let(:child2_work_package) do
+ create_child(following_work_package1,
+ child2_start_date,
+ child2_due_date,
+ schedule_manually: false)
+ end
let!(:following) do
[following_work_package1,
@@ -865,6 +905,7 @@ RSpec.describe WorkPackages::SetScheduleService do
def create_hierarchy(parent, nb_children_by_levels)
nb_children, *remaining_levels = nb_children_by_levels
children = create_list(:work_package, nb_children, parent:)
+ parent.update(schedule_manually: false)
if remaining_levels.any?
children.each do |child|
create_hierarchy(child, remaining_levels)
diff --git a/spec/services/work_packages/set_schedule_service_working_days_spec.rb b/spec/services/work_packages/set_schedule_service_working_days_spec.rb
index 40fea3fc684..efd102b9727 100644
--- a/spec/services/work_packages/set_schedule_service_working_days_spec.rb
+++ b/spec/services/work_packages/set_schedule_service_working_days_spec.rb
@@ -42,943 +42,982 @@ RSpec.describe WorkPackages::SetScheduleService, "working days" do
context "with a single successor" do
context "when moving successor will cover non-working days" do
- let_work_packages(<<~CHART)
- subject | MTWTFSS | properties
- work_package | XX |
- follower | XXX | follows work_package
- CHART
+ let_work_packages(<<~TABLE)
+ subject | MTWTFSS | scheduling mode | properties
+ work_package | XX | manual |
+ follower | XXX | automatic | follows work_package
+ TABLE
before do
- change_schedule([work_package], <<~CHART)
- days | MTWTFSS |
+ change_work_packages([work_package], <<~TABLE)
+ subject | MTWTFSS |
work_package | XXXX |
- CHART
+ TABLE
end
it "extends to a later due date to keep the same duration" do
- expect_work_packages(subject.all_results, <<~CHART)
+ expect_work_packages(subject.all_results, <<~TABLE)
subject | MTWTFSS |
work_package | XXXX |
follower | X..XX |
- CHART
+ TABLE
expect(follower.duration).to eq(3)
end
end
context "when moved predecessor covers non-working days" do
- let_schedule(<<~CHART)
- days | MTWTFSS |
- work_package | XX |
- follower | XXX | follows work_package
- CHART
+ let_work_packages(<<~TABLE)
+ subject | MTWTFSS | scheduling mode | properties
+ work_package | XX | manual |
+ follower | XXX | automatic | follows work_package
+ TABLE
before do
- change_schedule([work_package], <<~CHART)
- days | MTWTFSS |
+ change_work_packages([work_package], <<~TABLE)
+ subject | MTWTFSS |
work_package | XX..XX |
- CHART
+ TABLE
end
it "extends to a later due date to keep the same duration" do
- expect_schedule(subject.all_results, <<~CHART)
- days | MTWTFSS |
+ expect_work_packages(subject.all_results, <<~TABLE)
+ subject | MTWTFSS |
work_package | XX..XX |
follower | XXX |
- CHART
+ TABLE
expect(follower.duration).to eq(3)
end
end
context "when predecessor moved forward" do
context "on a day in the middle on working days with the follower having only start date" do
- let_schedule(<<~CHART)
- days | MTWTFSS |
- work_package | X |
- follower | [ | follows work_package
- CHART
+ let_work_packages(<<~TABLE)
+ subject | MTWTFSS | scheduling mode | properties
+ work_package | X | manual |
+ follower | [ | automatic | follows work_package
+ TABLE
before do
- change_schedule([work_package], <<~CHART)
- days | MTWTFSS |
+ change_work_packages([work_package], <<~TABLE)
+ subject | MTWTFSS |
work_package | XXXX |
- CHART
+ TABLE
end
it "reschedules follower to start the next day after its predecessor due date" do
- expect_schedule(subject.all_results, <<~CHART)
- | MTWTFSS |
+ expect_work_packages(subject.all_results, <<~TABLE)
+ subject | MTWTFSS |
work_package | XXXX |
follower | [ |
- CHART
+ TABLE
end
end
context "on a day just before non working days with the follower having only start date" do
- let_schedule(<<~CHART)
- days | MTWTFSS |
- work_package | X |
- follower | [ | follows work_package
- CHART
+ let_work_packages(<<~TABLE)
+ subject | MTWTFSS | scheduling mode | properties
+ work_package | X | manual |
+ follower | [ | automatic | follows work_package
+ TABLE
before do
- change_schedule([work_package], <<~CHART)
- days | MTWTFSS |
+ change_work_packages([work_package], <<~TABLE)
+ subject | MTWTFSS |
work_package | XXXXX |
- CHART
+ TABLE
end
it "reschedules follower to start after the non working days" do
- expect_schedule(subject.all_results, <<~CHART)
- | MTWTFSS |
+ expect_work_packages(subject.all_results, <<~TABLE)
+ subject | MTWTFSS |
work_package | XXXXX |
follower | [ |
- CHART
+ TABLE
end
end
context "on a day in the middle of working days with the follower having only due date and no space in between" do
- let_schedule(<<~CHART)
- days | MTWTFSS |
- work_package | ] |
- follower | ] | follows work_package
- CHART
+ let_work_packages(<<~TABLE)
+ subject | MTWTFSS | scheduling mode | properties
+ work_package | ] | manual |
+ follower | ] | automatic | follows work_package
+ TABLE
before do
- change_schedule([work_package], <<~CHART)
- days | MTWTFSS |
+ change_work_packages([work_package], <<~TABLE)
+ subject | MTWTFSS |
work_package | ] |
- CHART
+ TABLE
end
it "reschedules follower to start and end right after its predecessor with a default duration of 1 day" do
- expect_schedule(subject.all_results, <<~CHART)
- | MTWTFSS |
+ expect_work_packages(subject.all_results, <<~TABLE)
+ subject | MTWTFSS |
work_package | ] |
follower | X |
- CHART
+ TABLE
end
end
context "on a day in the middle of working days with the follower having only due date and much space in between" do
- let_schedule(<<~CHART)
- days | MTWTFSSmt |
- work_package | ] |
- follower | ] | follows work_package
- CHART
+ let_work_packages(<<~TABLE)
+ subject | MTWTFSSmt | scheduling mode | properties
+ work_package | ] | manual |
+ follower | ] | automatic | follows work_package
+ TABLE
before do
- change_schedule([work_package], <<~CHART)
- days | MTWTFSS |
+ change_work_packages([work_package], <<~TABLE)
+ subject | MTWTFSS |
work_package | ] |
- CHART
+ TABLE
end
it "reschedules follower to start after its predecessor without needing to change the end date" do
- expect_schedule(subject.all_results, <<~CHART)
- | MTWTFSS |
+ expect_work_packages(subject.all_results, <<~TABLE)
+ subject | MTWTFSS |
work_package | ] |
follower | X..XX |
- CHART
+ TABLE
end
end
context "on a day just before non-working day with the follower having only due date" do
- let_schedule(<<~CHART)
- days | MTWTFSS |
- work_package | ] |
- follower | ] | follows work_package
- CHART
+ let_work_packages(<<~TABLE)
+ subject | MTWTFSS | scheduling mode | properties
+ work_package | ] | manual |
+ follower | ] | automatic | follows work_package
+ TABLE
before do
- change_schedule([work_package], <<~CHART)
- days | MTWTFSS |
+ change_work_packages([work_package], <<~TABLE)
+ subject | MTWTFSS |
work_package | ] |
- CHART
+ TABLE
end
it "reschedules follower to start and end after the non working days with a default duration of 1 day" do
- expect_schedule(subject.all_results, <<~CHART)
- | MTWTFSS |
+ expect_work_packages(subject.all_results, <<~TABLE)
+ subject | MTWTFSS |
work_package | ] |
follower | X |
- CHART
+ TABLE
end
end
context "with the follower having some space left" do
- let_schedule(<<~CHART)
- days | MTWTFSS |
- work_package | X |
- follower | X..XX | follows work_package
- CHART
+ let_work_packages(<<~TABLE)
+ subject | MTWTFSS | scheduling mode | properties
+ work_package | X | manual |
+ follower | X..XX | automatic | follows work_package
+ TABLE
before do
- change_schedule([work_package], <<~CHART)
- days | MTWTFSS |
+ change_work_packages([work_package], <<~TABLE)
+ subject | MTWTFSS |
work_package | XXXXX |
- CHART
+ TABLE
end
it "reschedules follower to start the next working day after its predecessor due date" do
- expect_schedule(subject.all_results, <<~CHART)
- | MTWTFSS |
+ expect_work_packages(subject.all_results, <<~TABLE)
+ subject | MTWTFSS |
work_package | XXXXX |
follower | XXX |
- CHART
+ TABLE
end
end
context "with the follower having enough space left to not be moved at all" do
- let_schedule(<<~CHART)
- days | MTWTFSS |
- work_package | X |
- follower | XXX | follows work_package
- CHART
+ let_work_packages(<<~TABLE)
+ subject | MTWTFSS | scheduling mode | properties
+ work_package | X | manual |
+ follower | XXX | automatic | follows work_package
+ TABLE
before do
- change_schedule([work_package], <<~CHART)
- days | MTWTFSS |
+ change_work_packages([work_package], <<~TABLE)
+ subject | MTWTFSS |
work_package | XXXXX..X |
- CHART
+ TABLE
end
it "does not move follower" do
- expect_schedule(subject.all_results, <<~CHART)
- | MTWTFSS |
+ expect_work_packages(subject.all_results, <<~TABLE)
+ subject | MTWTFSS |
work_package | XXXXX..X |
- CHART
- expect_schedule([follower], <<~CHART)
- | MTWTFSS |
+ TABLE
+ expect_work_packages([follower], <<~TABLE)
+ subject | MTWTFSS |
follower | XXX |
- CHART
+ TABLE
end
end
context "with the follower having some space left and a lag" do
- let_schedule(<<~CHART)
- days | MTWTFSSmtwtfss |
- work_package | X |
- follower | XXX | follows work_package with lag 3
- CHART
+ let_work_packages(<<~TABLE)
+ subject | MTWTFSSmtwtfss | scheduling mode | properties
+ work_package | X | manual |
+ follower | XXX | automatic | follows work_package with lag 3
+ TABLE
before do
- change_schedule([work_package], <<~CHART)
- days | MTWTFSS |
+ change_work_packages([work_package], <<~TABLE)
+ subject | MTWTFSS |
work_package | XXXXX..X |
- CHART
+ TABLE
end
it "reschedules the follower to start after the lag" do
- expect_schedule(subject.all_results, <<~CHART)
- | MTWTFSSmtwtfss |
+ expect_work_packages(subject.all_results, <<~TABLE)
+ subject | MTWTFSSmtwtfss |
work_package | XXXXX..X |
follower | X..XX |
- CHART
+ TABLE
end
end
context "with the follower having a lag overlapping non-working days" do
- let_schedule(<<~CHART)
- days | MTWTFSS |
- work_package | X |
- follower | XX | follows work_package with lag 2
- CHART
+ let_work_packages(<<~TABLE)
+ subject | MTWTFSS | scheduling mode | properties
+ work_package | X | manual |
+ follower | XX | automatic | follows work_package with lag 2
+ TABLE
before do
- change_schedule([work_package], <<~CHART)
- days | MTWTFSS |
+ change_work_packages([work_package], <<~TABLE)
+ subject | MTWTFSS |
work_package | X |
- CHART
+ TABLE
end
it "reschedules the follower to start after the non-working days and the lag" do
- expect(subject.all_results).to match_schedule(<<~CHART)
- | MTWTFSSmtwt |
+ expect_work_packages(subject.all_results, <<~TABLE)
+ subject | MTWTFSSmtwt |
work_package | X |
follower | XX |
- CHART
+ TABLE
end
end
end
context "when predecessor moved backwards" do
context "on a day right before some non-working days" do
- let_schedule(<<~CHART)
- days | MTWTFSS |
- work_package | X |
- follower | XX | follows work_package
- CHART
+ let_work_packages(<<~TABLE)
+ subject | MTWTFSS | scheduling mode | properties
+ work_package | X | manual |
+ follower | XX | automatic | follows work_package
+ TABLE
before do
- change_schedule([work_package], <<~CHART)
- days | MTWTFSS |
+ change_work_packages([work_package], <<~TABLE)
+ subject | MTWTFSS |
work_package | X |
- CHART
+ TABLE
end
it "does not move the follower" do
- expect(subject.all_results).to match_schedule(<<~CHART)
- | MTWTFSS |
+ expect_work_packages(subject.all_results, <<~TABLE)
+ subject | MTWTFSS |
work_package | X |
- CHART
+ TABLE
end
end
context "on a day before non-working days the follower having space between" do
- let_schedule(<<~CHART)
- days | MTWTFSS |
- work_package | X |
- follower | X | follows work_package
- CHART
+ let_work_packages(<<~TABLE)
+ subject | MTWTFSS | scheduling mode | properties
+ work_package | X | manual |
+ follower | X | automatic | follows work_package
+ TABLE
before do
- change_schedule([work_package], <<~CHART)
- days | MTWTFSS |
+ change_work_packages([work_package], <<~TABLE)
+ subject | MTWTFSS |
work_package | X |
- CHART
+ TABLE
end
it "does not move the follower" do
- expect(subject.all_results).to match_schedule(<<~CHART)
- | MTWTFSS |
+ expect_work_packages(subject.all_results, <<~TABLE)
+ subject | MTWTFSS |
work_package | X |
- CHART
+ TABLE
end
end
context "with the follower having another relation limiting movement" do
- let_schedule(<<~CHART)
- days | mtwtfssmtwtfssMTWTFSS |
- work_package | X |
- follower | XX | follows work_package, follows annoyer with lag 2
- annoyer | XX..XX |
- CHART
+ let_work_packages(<<~TABLE)
+ subject | mtwtfssmtwtfssMTWTFSS | scheduling mode | properties
+ work_package | X | manual |
+ follower | XX | automatic | follows work_package, follows annoyer with lag 2
+ annoyer | XX..XX | manual |
+ TABLE
before do
- change_schedule([work_package], <<~CHART)
- days | mtwtfssmtwtfssMTWTFSS |
+ change_work_packages([work_package], <<~TABLE)
+ subject | mtwtfssmtwtfssMTWTFSS |
work_package | X |
- CHART
+ TABLE
end
it "does not move the follower" do
- expect(subject.all_results).to match_schedule(<<~CHART)
- days | mtwtfssmtwtfssMTWTFSS |
+ expect_work_packages(subject.all_results, <<~TABLE)
+ subject | mtwtfssmtwtfssMTWTFSS |
work_package | X |
- CHART
+ TABLE
end
end
end
context "when removing the dates on the moved predecessor" do
context "with the follower having start and due dates" do
- let_schedule(<<~CHART)
- days | MTWTFSS |
- work_package | XX |
- follower | XXX | follows work_package
- CHART
+ let_work_packages(<<~TABLE)
+ subject | MTWTFSS | scheduling mode | properties
+ work_package | XX | manual |
+ follower | XXX | automatic | follows work_package
+ TABLE
before do
- change_schedule([work_package], <<~CHART)
- days | MTWTFSS |
+ change_work_packages([work_package], <<~TABLE)
+ subject | MTWTFSS |
work_package | |
- CHART
+ TABLE
end
it "does not reschedule and follower keeps its dates" do
- expect_schedule(subject.all_results, <<~CHART)
- days | MTWTFSS |
+ expect_work_packages(subject.all_results, <<~TABLE)
+ subject | MTWTFSS |
work_package | |
- CHART
- expect_schedule([follower], <<~CHART)
- days | MTWTFSS |
+ TABLE
+ expect_work_packages([follower], <<~TABLE)
+ subject | MTWTFSS |
follower | XXX |
- CHART
+ TABLE
end
end
context "with the follower having only a due date" do
- let_schedule(<<~CHART)
- days | MTWTFSS |
- work_package | XX |
- follower | ] | follows work_package
- CHART
+ let_work_packages(<<~TABLE)
+ subject | MTWTFSS | scheduling mode | properties
+ work_package | XX | manual |
+ follower | ] | automatic | follows work_package
+ TABLE
before do
- change_schedule([work_package], <<~CHART)
- days | MTWTFSS |
+ change_work_packages([work_package], <<~TABLE)
+ subject | MTWTFSS |
work_package | |
- CHART
+ TABLE
end
it "does not reschedule and follower keeps its dates" do
- expect_schedule(subject.all_results, <<~CHART)
- days | MTWTFSS |
+ expect_work_packages(subject.all_results, <<~TABLE)
+ subject | MTWTFSS |
work_package | |
- CHART
- expect_schedule([follower], <<~CHART)
- days | MTWTFSS |
+ TABLE
+ expect_work_packages([follower], <<~TABLE)
+ subject | MTWTFSS |
follower | ] |
- CHART
+ TABLE
end
end
end
context "when only creating the relation between predecessor and follower" do
context "with follower having no dates" do
- let_schedule(<<~CHART)
- days | MTWTFSS |
+ let_work_packages(<<~TABLE)
+ subject | MTWTFSS |
work_package | XX |
follower | |
- CHART
+ TABLE
before do
create(:follows_relation, from: follower, to: work_package)
+ follower.update_column(:schedule_manually, false)
end
it "schedules follower to start right after its predecessor and does not set the due date" do
- expect(subject.all_results).to match_schedule(<<~CHART)
- days | MTWTFSS |
+ expect_work_packages(subject.all_results, <<~TABLE)
+ subject | MTWTFSS |
work_package | XX |
follower | [ |
- CHART
+ TABLE
end
end
context "with follower having only due date before predecessor due date" do
- let_schedule(<<~CHART)
- days | MTWTFSS |
+ let_work_packages(<<~TABLE)
+ subject | MTWTFSS |
work_package | XX |
follower | ] |
- CHART
+ TABLE
before do
create(:follows_relation, from: follower, to: work_package)
+ follower.update_column(:schedule_manually, false)
end
it "reschedules follower to start right after its predecessor and end the same day" do
- expect(subject.all_results).to match_schedule(<<~CHART)
- days | MTWTFSS |
+ expect_work_packages(subject.all_results, <<~TABLE)
+ subject | MTWTFSS |
work_package | XX |
follower | X |
- CHART
+ TABLE
end
end
context "with follower having only start date before predecessor due date" do
- let_schedule(<<~CHART)
- days | MTWTFSS |
+ let_work_packages(<<~TABLE)
+ subject | MTWTFSS |
work_package | XX |
follower | [ |
- CHART
+ TABLE
before do
create(:follows_relation, from: follower, to: work_package)
+ follower.update_column(:schedule_manually, false)
end
it "reschedules follower to start right after its predecessor and leaves the due date unset" do
- expect(subject.all_results).to match_schedule(<<~CHART)
- days | MTWTFSS |
+ expect_work_packages(subject.all_results, <<~TABLE)
+ subject | MTWTFSS |
work_package | XX |
follower | [ |
- CHART
+ TABLE
end
end
context "with follower having both start and due dates before predecessor due date" do
- let_schedule(<<~CHART)
- days | mtwtfssMTWTFSS |
+ let_work_packages(<<~TABLE)
+ subject | mtwtfssMTWTFSS |
work_package | XX |
follower | X..XXX |
- CHART
+ TABLE
before do
create(:follows_relation, from: follower, to: work_package)
+ follower.update_column(:schedule_manually, false)
end
it "reschedules follower to start right after its predecessor and keeps the duration" do
- expect(subject.all_results).to match_schedule(<<~CHART)
- days | MTWTFSS |
+ expect_work_packages(subject.all_results, <<~TABLE)
+ subject | MTWTFSS |
work_package | XX |
follower | XXX..X |
- CHART
+ TABLE
end
end
context "with follower having due date long after predecessor due date" do
- let_schedule(<<~CHART)
- days | MTWTFSS |
+ let_work_packages(<<~TABLE)
+ subject | MTWTFSS |
work_package | XX |
follower | ] |
- CHART
+ TABLE
before do
create(:follows_relation, from: follower, to: work_package)
+ follower.update_column(:schedule_manually, false)
end
it "reschedules follower to start right after its predecessor and end the same day" do
- expect(subject.all_results).to match_schedule(<<~CHART)
- days | MTWTFSS |
+ expect_work_packages(subject.all_results, <<~TABLE)
+ subject | MTWTFSS |
work_package | XX |
follower | XXX |
- CHART
+ TABLE
end
end
context "with predecessor and follower having no dates" do
- let_schedule(<<~CHART)
- days | MTWTFSS |
+ let_work_packages(<<~TABLE)
+ subject | MTWTFSS |
work_package | |
follower | |
- CHART
+ TABLE
before do
create(:follows_relation, from: follower, to: work_package)
+ follower.update_column(:schedule_manually, false)
end
it "does not reschedule any work package" do
- expect(subject.all_results).to match_schedule(<<~CHART)
- days | MTWTFSS |
+ expect_work_packages(subject.all_results, <<~TABLE)
+ subject | MTWTFSS |
work_package | |
- CHART
+ TABLE
end
end
end
context "with the successor having another predecessor which has no dates" do
context "when moved forward" do
- let_schedule(<<~CHART)
- days | MTWTFSS |
- work_package | ] |
- follower | XXX | follows work_package, follows other_predecessor
- other_predecessor | |
- CHART
+ let_work_packages(<<~TABLE)
+ subject | MTWTFSS | scheduling mode | properties
+ work_package | ] | manual |
+ follower | XXX | automatic | follows work_package, follows other_predecessor
+ other_predecessor | | manual |
+ TABLE
before do
- change_schedule([work_package], <<~CHART)
- days | MTWTFSS |
+ change_work_packages([work_package], <<~TABLE)
+ subject | MTWTFSS |
work_package | ] |
- CHART
+ TABLE
end
it "reschedules follower without influence from the other predecessor" do
- expect(subject.all_results).to match_schedule(<<~CHART)
- days | MTWTFSS |
+ expect_work_packages(subject.all_results, <<~TABLE)
+ subject | MTWTFSS |
work_package | ] |
follower | X..XX |
- CHART
+ TABLE
end
end
context "when moved backwards" do
- let_schedule(<<~CHART)
- days | MTWTFSS |
- work_package | ] |
- follower | XXX | follows work_package, follows other_predecessor
- other_predecessor | |
- CHART
+ let_work_packages(<<~TABLE)
+ subject | MTWTFSS | scheduling mode | properties
+ work_package | ] | manual |
+ follower | XXX | automatic | follows work_package, follows other_predecessor
+ other_predecessor | | manual |
+ TABLE
before do
- change_schedule([work_package], <<~CHART)
- days | mtwtfssMTWTFSS |
+ change_work_packages([work_package], <<~TABLE)
+ subject | mtwtfssMTWTFSS |
work_package | ] |
- CHART
+ TABLE
end
it "does not move the follower" do
- expect(subject.all_results).to match_schedule(<<~CHART)
- days | mtwtfssMTWTFSS |
+ expect_work_packages(subject.all_results, <<~TABLE)
+ subject | mtwtfssMTWTFSS |
work_package | ] |
- CHART
+ TABLE
end
end
end
context "with successor having only duration" do
context "when setting dates on predecessor" do
- let_schedule(<<~CHART)
- days | MTWTFSS |
- work_package | |
- follower | | duration 3, follows work_package
- CHART
+ let_work_packages(<<~TABLE)
+ subject | MTWTFSS | duration | scheduling mode | properties
+ work_package | | | manual |
+ follower | | 3 | automatic | follows work_package
+ TABLE
before do
- change_schedule([work_package], <<~CHART)
- days | MTWTFSS |
+ change_work_packages([work_package], <<~TABLE)
+ subject | MTWTFSS |
work_package | XX |
- CHART
+ TABLE
end
it "schedules successor to start after predecessor and keeps the duration (#44479)" do
- expect(subject.all_results).to match_schedule(<<~CHART)
- days | MTWTFSS |
+ expect_work_packages(subject.all_results, <<~TABLE)
+ subject | MTWTFSS |
work_package | XX |
follower | X..XX |
- CHART
+ TABLE
end
end
end
end
context "with a parent" do
- let_schedule(<<~CHART)
- days | MTWTFSS |
- parent | |
- work_package | ] | child of parent
- CHART
+ let_work_packages(<<~TABLE)
+ hierarchy | MTWTFSS | scheduling mode
+ parent | | automatic
+ work_package | ] | manual
+ TABLE
before do
- change_schedule([work_package], <<~CHART)
- days | mtwtfssMTWTFSS |
+ change_work_packages([work_package], <<~TABLE)
+ subject | mtwtfssMTWTFSS |
work_package | XXX..X |
- CHART
+ TABLE
end
it "reschedules parent to have the same dates as the child" do
- expect(subject.all_results).to match_schedule(<<~CHART)
- days | mtwtfssMTWTFSS |
+ expect_work_packages(subject.all_results, <<~TABLE)
+ subject | mtwtfssMTWTFSS |
parent | XXX..X |
work_package | XXX..X |
- CHART
+ TABLE
end
end
context "with a parent having a follower" do
- let_schedule(<<~CHART)
- days | MTWTFSS |
- parent | XX |
- work_package | ] | child of parent
- parent_follower | X..XX | follows parent
- CHART
+ let_work_packages(<<~TABLE)
+ hierarchy | MTWTFSS | scheduling mode | properties
+ parent | XX | automatic |
+ work_package | ] | manual |
+ parent_follower | X..XX | automatic | follows parent
+ TABLE
before do
- change_schedule([work_package], <<~CHART)
- days | MTWTFSS |
+ change_work_packages([work_package], <<~TABLE)
+ subject | MTWTFSS |
work_package | XXXXX |
- CHART
+ TABLE
end
it "reschedules parent to have the same dates as the child, and parent follower to start right after parent" do
- expect(subject.all_results).to match_schedule(<<~CHART)
- days | MTWTFSS |
+ expect_work_packages(subject.all_results, <<~TABLE)
+ subject | MTWTFSS |
parent | XXXXX |
work_package | XXXXX |
parent_follower | XXX |
- CHART
+ TABLE
end
end
context "with a single successor having a parent" do
context "when moving forward" do
- let_schedule(<<~CHART)
- days | MTWTFSS |
- work_package | ] |
- follower | XX | follows work_package, child of follower_parent
- follower_parent | XX |
- CHART
+ let_work_packages(<<~TABLE)
+ hierarchy | MTWTFSS | scheduling mode | properties
+ work_package | ] | manual |
+ follower_parent | XX | automatic |
+ follower | XX | automatic | follows work_package
+ TABLE
before do
- change_schedule([work_package], <<~CHART)
- days | MTWTFSS |
+ change_work_packages([work_package], <<~TABLE)
+ subject | MTWTFSS |
work_package | ] |
- CHART
+ TABLE
end
it "reschedules follower and follower parent to start right after the moved predecessor" do
- expect(subject.all_results).to match_schedule(<<~CHART)
- days | MTWTFSS |
+ expect_work_packages(subject.all_results, <<~TABLE)
+ subject | MTWTFSS |
work_package | ] |
follower | X..X |
follower_parent | X..X |
- CHART
+ TABLE
end
end
context "when moving forward with the parent having another child not being moved" do
- let_schedule(<<~CHART)
- days | MTWTFSS |
- work_package | ] |
- follower | XX | follows work_package, child of follower_parent
- follower_sibling | XXX | child of follower_parent
- follower_parent | XXXX |
- CHART
+ let_work_packages(<<~TABLE)
+ hierarchy | MTWTFSS | scheduling mode | properties
+ work_package | ] | manual |
+ follower_parent | XXXX | automatic |
+ follower | XX | automatic | follows work_package
+ follower_sibling | XXX | manual |
+ TABLE
before do
- change_schedule([work_package], <<~CHART)
- days | MTWTFSS |
+ change_work_packages([work_package], <<~TABLE)
+ subject | MTWTFSS |
work_package | ] |
- CHART
+ TABLE
end
it "reschedules follower to start right after the moved predecessor, and follower parent spans on its two children" do
- expect(subject.all_results).to match_schedule(<<~CHART)
- days | MTWTFSS |
- work_package | ] |
- follower | X..X |
- follower_parent | XXX..X |
- CHART
+ expect_work_packages(subject.all_results, <<~TABLE)
+ subject | MTWTFSS |
+ work_package | ] |
+ follower_parent | XXX..X |
+ follower | X..X |
+ TABLE
+ expect_work_packages([follower_sibling], <<~TABLE)
+ subject | MTWTFSS |
+ follower_sibling | XXX |
+ TABLE
end
end
context "when moving backwards" do
- let_schedule(<<~CHART)
- days | MTWTFSS |
- work_package | ] |
- follower | XX | follows work_package, child of follower_parent
- follower_parent | XX |
- CHART
+ let_work_packages(<<~TABLE)
+ hierarchy | MTWTFSS | scheduling mode | properties
+ work_package | ] | manual |
+ follower_parent | XX | automatic |
+ follower | XX | automatic | follows work_package
+ TABLE
before do
- change_schedule([work_package], <<~CHART)
- days | mtwtfssMTWTFSS |
+ change_work_packages([work_package], <<~TABLE)
+ subject | mtwtfssMTWTFSS |
work_package | ] |
- CHART
+ TABLE
end
it "does not reschedule the followers" do
- expect(subject.all_results).to match_schedule(<<~CHART)
- days | mtwtfssMTWTFSS |
+ expect_work_packages(subject.all_results, <<~TABLE)
+ subject | mtwtfssMTWTFSS |
work_package | ] |
- CHART
+ TABLE
end
end
context "when moving backwards with the parent having another child not being moved" do
- let_schedule(<<~CHART)
- days | mtwtfssMTWTFSS |
- work_package | ] |
- follower | XX | follows work_package, child of follower_parent
- follower_sibling | XXX | child of follower_parent
- follower_parent | XXXX |
- CHART
+ let_work_packages(<<~TABLE)
+ hierarchy | mtwtfssMTWTFSS | scheduling mode | properties
+ work_package | ] | manual |
+ follower_parent | XXXX | automatic |
+ follower | XX | automatic | follows work_package
+ follower_sibling | XXX | manual |
+ TABLE
before do
- change_schedule([work_package], <<~CHART)
- days | mtwtfssMTWTFSS |
+ change_work_packages([work_package], <<~TABLE)
+ subject | mtwtfssMTWTFSS |
work_package | ] |
- CHART
+ TABLE
end
it "does not rechedule the followers or the other child" do
- expect(subject.all_results).to match_schedule(<<~CHART)
- days | mtwtfssMTWTFSS |
+ expect_work_packages(subject.all_results, <<~TABLE)
+ subject | mtwtfssMTWTFSS |
work_package | ] |
- CHART
+ TABLE
end
end
end
- context "with a single successor having a child" do
+ context "with a single successor having a child in automatic scheduling mode" do
context "when moving forward" do
- let_schedule(<<~CHART)
- days | MTWTFSS |
- work_package | ] |
- follower | XX | follows work_package
- follower_child | XX | child of follower
- CHART
+ let_work_packages(<<~TABLE)
+ hierarchy | MTWTFSS | scheduling mode | properties
+ work_package | ] | manual |
+ follower | XX | automatic | follows work_package
+ follower_child | XX | automatic |
+ TABLE
before do
- change_schedule([work_package], <<~CHART)
- days | MTWTFSS |
+ change_work_packages([work_package], <<~TABLE)
+ subject | MTWTFSS |
work_package | ] |
- CHART
+ TABLE
end
it "reschedules follower and follower child to start right after the moved predecessor" do
- expect(subject.all_results).to match_schedule(<<~CHART)
- days | MTWTFSS |
+ expect_work_packages(subject.all_results, <<~TABLE)
+ subject | MTWTFSS |
work_package | ] |
follower | X..X |
follower_child | X..X |
- CHART
+ TABLE
+ end
+ end
+ end
+
+ context "with a single successor having a child in manual scheduling mode" do
+ context "when moving forward" do
+ let_work_packages(<<~TABLE)
+ hierarchy | MTWTFSS | scheduling mode | properties
+ work_package | ] | manual |
+ follower | XX | automatic | follows work_package
+ follower_child | XX | manual |
+ TABLE
+
+ before do
+ change_work_packages([work_package], <<~TABLE)
+ subject | MTWTFSS |
+ work_package | ] |
+ TABLE
+ end
+
+ it "does not reschedule follower as dates depend on follower child which is manually scheduled" do
+ expect_work_packages(subject.all_results, <<~TABLE)
+ subject | MTWTFSS |
+ work_package | ] |
+ TABLE
end
end
end
- context "with a single successor having two children" do
+ context "with a single successor having two children automatically scheduled" do
context "when creating the follows relation while follower starts 1 day after moved due date" do
- let_schedule(<<~CHART)
- days | MTWTFSS |
- work_package | ] |
- follower | XXXX..XXXXX..XX |
- follower_child1 | XXX | child of follower
- follower_child2 | X..XX | child of follower
- CHART
+ let_work_packages(<<~TABLE)
+ hierarchy | MTWTFSS | scheduling mode | properties
+ work_package | ] | manual |
+ follower | XXXX..XXXXX..XX | automatic |
+ follower_child1 | XXX | automatic |
+ follower_child2 | X..XX | automatic |
+ TABLE
before do
create(:follows_relation, from: follower, to: work_package)
end
it "does not need to reschedule anything" do
- expect(subject.all_results).to match_schedule(<<~CHART)
- days | MTWTFSS |
+ expect_work_packages(subject.all_results, <<~TABLE)
+ subject | MTWTFSS |
work_package | ] |
- CHART
+ TABLE
end
end
context "when creating the follows relation while follower starts 3 days after moved due date" do
- let_schedule(<<~CHART)
- days | MTWTFSS |
- work_package | ] |
- follower | XX..XXXXX..XXXX |
- follower_child1 | XX..X | child of follower
- follower_child2 | XXX | child of follower
- CHART
+ let_work_packages(<<~TABLE)
+ hierarchy | MTWTFSS | scheduling mode |
+ work_package | ] | manual |
+ follower | XX..XXXXX..XXXX | automatic |
+ follower_child1 | XX..X | automatic |
+ follower_child2 | XXX | automatic |
+ TABLE
before do
create(:follows_relation, from: follower, to: work_package)
end
it "does not need to reschedule anything" do
- expect(subject.all_results).to match_schedule(<<~CHART)
- days | MTWTFSS |
+ expect_work_packages(subject.all_results, <<~TABLE)
+ subject | MTWTFSS |
work_package | ] |
- CHART
+ TABLE
end
end
context "when creating the follows relation and follower first child starts before moved due date" do
- let_schedule(<<~CHART)
- days | MTWTFSS |
- work_package | ] |
- follower | X..XXXXX..XXXX |
- follower_child1 | X..XXXX | child of follower
- follower_child2 | X..XXXX | child of follower
- CHART
+ let_work_packages(<<~TABLE)
+ hierarchy | MTWTFSS | scheduling mode |
+ work_package | ] | manual |
+ follower | X..XXXXX..XXXX | automatic |
+ follower_child1 | X..XXXX | automatic |
+ follower_child2 | X..XXXX | automatic |
+ TABLE
before do
create(:follows_relation, from: follower, to: work_package)
end
it "reschedules first child and reduces follower parent duration as the children can be executed at the same time" do
- expect(subject.all_results).to match_schedule(<<~CHART)
- days | MTWTFSS |
+ expect_work_packages(subject.all_results, <<~TABLE)
+ subject | MTWTFSS |
work_package | ] |
follower | XXXX..XXXX |
follower_child1 | XXXX..X |
- CHART
+ TABLE
+ expect_work_packages([follower_child2], <<~TABLE)
+ subject | MTWTFSS |
+ follower_child2 | X..XXXX |
+ TABLE
end
end
context "when creating the follows relation and both follower children start before moved due date" do
- let_schedule(<<~CHART)
- days | MTWTFSS |
- work_package | ] |
- follower | XXX..XXXXX..X |
- follower_child1 | X | child of follower
- follower_child2 | X..XXXXX..X | child of follower
- CHART
+ let_work_packages(<<~TABLE)
+ hierarchy | MTWTFSS | scheduling mode |
+ work_package | ] | manual |
+ follower | XXX..XXXXX..X | automatic |
+ follower_child1 | X | automatic |
+ follower_child2 | X..XXXXX..X | automatic |
+ TABLE
before do
create(:follows_relation, from: follower, to: work_package)
end
it "reschedules both children and reduces follower parent duration" do
- expect(subject.all_results).to match_schedule(<<~CHART)
- days | MTWTFSS |
- work_package | ] |
- follower | XXXX..XXX |
- follower_child1 | X | child of follower
- follower_child2 | XXXX..XXX | child of follower
- CHART
+ expect_work_packages(subject.all_results, <<~TABLE)
+ subject | MTWTFSS |
+ work_package | ] |
+ follower | XXXX..XXX |
+ follower_child1 | X |
+ follower_child2 | XXXX..XXX |
+ TABLE
end
end
end
context "with a chain of followers" do
context "when moving forward" do
- let_schedule(<<~CHART)
- days | MTWTFSSm sm sm |
- work_package | ] |
- follower1 | XXX | follows work_package
- follower2 | X..XXXX | follows follower1
- follower3 | X..XXXX | follows follower2
- follower4 | X..X | follows follower3
- CHART
+ let_work_packages(<<~TABLE)
+ subject | MTWTFSSm sm sm | scheduling mode | properties
+ work_package | ] | manual |
+ follower1 | XXX | automatic | follows work_package
+ follower2 | X..XXXX | automatic | follows follower1
+ follower3 | X..XXXX | automatic | follows follower2
+ follower4 | X..X | automatic | follows follower3
+ TABLE
before do
- change_schedule([work_package], <<~CHART)
- days | MTWTFSS |
+ change_work_packages([work_package], <<~TABLE)
+ subject | MTWTFSS |
work_package | ] |
- CHART
+ TABLE
end
it "reschedules each follower forward by the same delta" do
- expect(subject.all_results).to match_schedule(<<~CHART)
- days | MTWTFSSm sm sm |
+ expect_work_packages(subject.all_results, <<~TABLE)
+ subject | MTWTFSSm sm sm |
work_package | ] |
- follower1 | X..XX | follows work_package
- follower2 | XXX..XX | follows follower1
- follower3 | XXXX..X | follows follower2
- follower4 | XX | follows follower3
- CHART
+ follower1 | X..XX |
+ follower2 | XXX..XX |
+ follower3 | XXXX..X |
+ follower4 | XX |
+ TABLE
end
end
context "when moving forward with some space between the followers" do
- let_schedule(<<~CHART)
- days | MTWTFSSm sm sm |
- work_package | ] |
- follower1 | XXX | follows work_package
- follower2 | XXXX | follows follower1
- follower3 | XXX..XX | follows follower2
- follower4 | XX | follows follower3
- CHART
+ let_work_packages(<<~TABLE)
+ subject | MTWTFSSm sm sm | scheduling mode | properties
+ work_package | ] | manual |
+ follower1 | XXX | automatic | follows work_package
+ follower2 | XXXX | automatic | follows follower1
+ follower3 | XXX..XX | automatic | follows follower2
+ follower4 | XX | automatic | follows follower3
+ TABLE
before do
- change_schedule([work_package], <<~CHART)
- days | MTWTFSS |
+ change_work_packages([work_package], <<~TABLE)
+ subject | MTWTFSS |
work_package | ] |
- CHART
+ TABLE
end
it "reschedules only the first followers as the others don't need to move" do
- expect(subject.all_results).to match_schedule(<<~CHART)
- days | MTWTFSSm sm |
+ expect_work_packages(subject.all_results, <<~TABLE)
+ subject | MTWTFSSm sm |
work_package | ] |
follower1 | X..XX |
follower2 | XXX..X |
- CHART
+ TABLE
end
end
context "when moving forward with some lag and spaces between the followers" do
- let_schedule(<<~CHART)
- days | MTWTFSSm sm sm |
- work_package | ] |
- follower1 | XXX | follows work_package
- follower2 | XXXX | follows follower1 with lag 3
- follower3 | XXX..XX | follows follower2
- follower4 | XX | follows follower3
- CHART
+ let_work_packages(<<~TABLE)
+ subject | MTWTFSSm sm sm | scheduling mode | properties
+ work_package | ] | manual |
+ follower1 | XXX | automatic | follows work_package
+ follower2 | XXXX | automatic | follows follower1 with lag 3
+ follower3 | XXX..XX | automatic | follows follower2
+ follower4 | XX | automatic | follows follower3
+ TABLE
before do
- change_schedule([work_package], <<~CHART)
- days | MTWTFSS |
+ change_work_packages([work_package], <<~TABLE)
+ subject | MTWTFSS |
work_package | ] |
- CHART
+ TABLE
end
it "reschedules all the followers keeping the lag and compacting the extra spaces" do
- expect(subject.all_results).to match_schedule(<<~CHART)
- days | MTWTFSSm sm sm sm |
+ expect_work_packages(subject.all_results, <<~TABLE)
+ subject | MTWTFSSm sm sm sm |
work_package | ] |
follower1 | X..XX |
follower2 | XXXX |
follower3 | X..XXXX |
follower4 | X..X |
- CHART
+ TABLE
end
end
context "when moving forward due to days and predecessor due date now being non-working days" do
- let_schedule(<<~CHART)
- days | MTWTFSS |
- work_package | XX |
- follower1 | X | follows work_package
- follower2 | XX | follows follower1
- CHART
+ let_work_packages(<<~TABLE)
+ subject | MTWTFSS | scheduling mode | properties
+ work_package | XX | manual |
+ follower1 | X | automatic | follows work_package
+ follower2 | XX | automatic | follows follower1
+ TABLE
before do
# Tuesday, Thursday, and Friday are now non-working days. So work_package
@@ -988,29 +1027,29 @@ RSpec.describe WorkPackages::SetScheduleService, "working days" do
# Below instructions reproduce the conditions in which such scheduling
# must happen.
set_non_working_week_days("tuesday", "thursday", "friday")
- change_schedule([work_package], <<~CHART)
- days | MTWTFSS |
+ change_work_packages([work_package], <<~TABLE)
+ subject | MTWTFSS |
work_package | X.X |
- CHART
+ TABLE
end
it "reschedules all the followers keeping the lag and compacting the extra spaces" do
- expect(subject.all_results).to match_schedule(<<~CHART)
- days | MTWTFSSm w m |
+ expect_work_packages(subject.all_results, <<~TABLE)
+ subject | MTWTFSSm w m |
work_package | X.X |
follower1 | X |
follower2 | X....X |
- CHART
+ TABLE
end
end
context "when moving forward due to days and predecessor start date now being non-working days" do
- let_schedule(<<~CHART)
- days | MTWTFSS |
- work_package | XX |
- follower1 | X | follows work_package
- follower2 | XX | follows follower1
- CHART
+ let_work_packages(<<~TABLE)
+ subject | MTWTFSS | scheduling mode | properties
+ work_package | XX | manual |
+ follower1 | X | automatic | follows work_package
+ follower2 | XX | automatic | follows follower1
+ TABLE
before do
# Monday, Thursday, and Friday are now non-working days. So work_package
@@ -1020,100 +1059,100 @@ RSpec.describe WorkPackages::SetScheduleService, "working days" do
# Below instructions reproduce the conditions in which such scheduling
# must happen.
set_non_working_week_days("monday", "thursday", "friday")
- change_schedule([work_package], <<~CHART)
- days | MTWTFSS |
+ change_work_packages([work_package], <<~TABLE)
+ subject | MTWTFSS |
work_package | XX |
- CHART
+ TABLE
end
it "reschedules all the followers without crossing each other" do
- expect(subject.all_results).to match_schedule(<<~CHART)
- days | MTWTFSS tw tw |
+ expect_work_packages(subject.all_results, <<~TABLE)
+ subject | MTWTFSS tw tw |
work_package | XX |
follower1 | X |
follower2 | X.....X |
- CHART
+ TABLE
end
end
context "when moving backwards" do
- let_schedule(<<~CHART)
- days | MTWTFSSm sm sm |
- work_package | ] |
- follower1 | XXX | follows work_package
- follower2 | X..XXX | follows follower1
- follower3 | XXX..XX | follows follower2
- follower4 | XX | follows follower3
- CHART
+ let_work_packages(<<~TABLE)
+ subject | MTWTFSSm sm sm | scheduling mode | properties
+ work_package | ] | manual |
+ follower1 | XXX | automatic | follows work_package
+ follower2 | X..XXX | automatic | follows follower1
+ follower3 | XXX..XX | automatic | follows follower2
+ follower4 | XX | automatic | follows follower3
+ TABLE
before do
- change_schedule([work_package], <<~CHART)
- days | m sMTWTFSS |
+ change_work_packages([work_package], <<~TABLE)
+ subject | m sMTWTFSS |
work_package | ] |
- CHART
+ TABLE
end
it "does not reschedule any followers" do
- expect(subject.all_results).to match_schedule(<<~CHART)
- days | m sMTWTFSS |
+ expect_work_packages(subject.all_results, <<~TABLE)
+ subject | m sMTWTFSS |
work_package | ] |
- CHART
+ TABLE
end
end
end
context "with a chain of followers with two paths leading to the same follower in the end" do
context "when moving forward" do
- let_schedule(<<~CHART)
- days | MTWTFSSm sm |
- work_package | ] |
- follower1 | XXX | follows work_package
- follower2 | X..XXXX | follows follower1
- follower3 | XX..X | follows work_package
- follower4 | X..XX | follows follower2, follows follower3
- CHART
+ let_work_packages(<<~TABLE)
+ subject | MTWTFSSm sm | scheduling mode | properties
+ work_package | ] | manual |
+ follower1 | XXX | automatic | follows work_package
+ follower2 | X..XXXX | automatic | follows follower1
+ follower3 | XX..X | automatic | follows work_package
+ follower4 | X..XX | automatic | follows follower2, follows follower3
+ TABLE
before do
- change_schedule([work_package], <<~CHART)
- days | MTWTFSS |
+ change_work_packages([work_package], <<~TABLE)
+ subject | MTWTFSS |
work_package | ] |
- CHART
+ TABLE
end
it "reschedules followers while satisfying all constraints" do
- expect(subject.all_results).to match_schedule(<<~CHART)
- days | MTWTFSSm sm sm |
+ expect_work_packages(subject.all_results, <<~TABLE)
+ subject | MTWTFSSm sm sm |
work_package | ] |
follower1 | XXX |
follower2 | XX..XXX |
follower3 | XXX |
follower4 | XX..X |
- CHART
+ TABLE
end
end
context "when moving backwards" do
- let_schedule(<<~CHART)
- days | MTWTFSSm sm |
- work_package | ] |
- follower1 | XXX | follows work_package
- follower2 | X..XXXX | follows follower1
- follower3 | XX..X | follows work_package
- follower4 | X..XX | follows follower2, follows follower3
- CHART
+ let_work_packages(<<~TABLE)
+ subject | MTWTFSSm sm | scheduling mode | properties
+ work_package | ] | manual |
+ follower1 | XXX | automatic | follows work_package
+ follower2 | X..XXXX | automatic | follows follower1
+ follower3 | XX..X | automatic | follows work_package
+ follower4 | X..XX | automatic | follows follower2, follows follower3
+ TABLE
before do
- change_schedule([work_package], <<~CHART)
- days | m sMTWTFSS |
+ change_work_packages([work_package], <<~TABLE)
+ subject | m sMTWTFSS |
work_package | ] |
- CHART
+ TABLE
end
it "does not reschedule any followers" do
- expect(subject.all_results).to match_schedule(<<~CHART)
- days | m sMTWTFSS |
+ expect_work_packages(subject.all_results, <<~TABLE)
+ subject | m sMTWTFSS |
work_package | ] |
- CHART
+ TABLE
end
end
end
@@ -1122,12 +1161,12 @@ RSpec.describe WorkPackages::SetScheduleService, "working days" do
let(:changed_attributes) { [:parent] }
context "without dates and with the parent being restricted in its ability to be moved" do
- let_schedule(<<~CHART)
- days | MTWTFSS |
- work_package | |
- new_parent | | follows new_parent_predecessor with lag 3
- new_parent_predecessor | X |
- CHART
+ let_work_packages(<<~TABLE)
+ subject | MTWTFSS | scheduling mode | properties
+ work_package | | manual |
+ new_parent_predecessor | X | manual |
+ new_parent | | automatic |follows new_parent_predecessor with lag 3
+ TABLE
before do
work_package.parent = new_parent
@@ -1135,21 +1174,21 @@ RSpec.describe WorkPackages::SetScheduleService, "working days" do
end
it "schedules parent to start and end at soonest working start date and the child to start at the parent start" do
- expect(subject.all_results).to match_schedule(<<~CHART)
- days | MTWTFSS |
+ expect_work_packages(subject.all_results, <<~TABLE)
+ subject | MTWTFSS |
work_package | [ |
new_parent | X |
- CHART
+ TABLE
end
end
context "without dates, with a duration and with the parent being restricted in its ability to be moved" do
- let_schedule(<<~CHART)
- days | MTWTFSS |
- work_package | | duration 4
- new_parent | | follows new_parent_predecessor with lag 3
- new_parent_predecessor | X |
- CHART
+ let_work_packages(<<~TABLE)
+ subject | MTWTFSS | duration | scheduling mode | properties
+ work_package | | 4 | manual |
+ new_parent_predecessor | X | | manual |
+ new_parent | | | automatic | follows new_parent_predecessor with lag 3
+ TABLE
before do
work_package.parent = new_parent
@@ -1158,21 +1197,21 @@ RSpec.describe WorkPackages::SetScheduleService, "working days" do
it "schedules the moved work package to start at the parent soonest date and sets due date to keep the same duration " \
"and schedules the parent dates to match the child dates" do
- expect(subject.all_results).to match_schedule(<<~CHART)
- days | MTWTFSS |
+ expect_work_packages(subject.all_results, <<~TABLE)
+ subject | MTWTFSS |
work_package | XXXX |
new_parent | XXXX |
- CHART
+ TABLE
end
end
context "with the parent being restricted in its ability to be moved and with a due date before parent constraint" do
- let_schedule(<<~CHART)
- days | MTWTFSS |
- work_package | ] |
- new_parent | | follows new_parent_predecessor with lag 3
- new_parent_predecessor | X |
- CHART
+ let_work_packages(<<~TABLE)
+ subject | MTWTFSS | scheduling mode | properties
+ work_package | ] | manual |
+ new_parent_predecessor | X | manual |
+ new_parent | | automatic | follows new_parent_predecessor with lag 3
+ TABLE
before do
work_package.parent = new_parent
@@ -1180,21 +1219,21 @@ RSpec.describe WorkPackages::SetScheduleService, "working days" do
end
it "schedules the moved work package to start and end at the parent soonest working start date" do
- expect(subject.all_results).to match_schedule(<<~CHART)
- days | MTWTFSS |
+ expect_work_packages(subject.all_results, <<~TABLE)
+ subject | MTWTFSS |
work_package | X |
new_parent | X |
- CHART
+ TABLE
end
end
context "with the parent being restricted in its ability to be moved and with a due date after parent constraint" do
- let_schedule(<<~CHART)
- days | MTWTFSS |
- work_package | ] |
- new_parent | | follows new_parent_predecessor with lag 3
- new_parent_predecessor | X |
- CHART
+ let_work_packages(<<~TABLE)
+ subject | MTWTFSS | scheduling mode | properties
+ work_package | ] | manual |
+ new_parent_predecessor | X | manual |
+ new_parent | | automatic | follows new_parent_predecessor with lag 3
+ TABLE
before do
work_package.parent = new_parent
@@ -1202,21 +1241,21 @@ RSpec.describe WorkPackages::SetScheduleService, "working days" do
end
it "schedules the moved work package to start at the parent soonest working start date and keep the due date" do
- expect(subject.all_results).to match_schedule(<<~CHART)
- days | MTWTFSS |
+ expect_work_packages(subject.all_results, <<~TABLE)
+ subject | MTWTFSS |
work_package | X..XX |
new_parent | X..XX |
- CHART
+ TABLE
end
end
context "with the parent being restricted but work package already has both dates set" do
- let_schedule(<<~CHART)
- days | MTWTFSS |
- work_package | XX |
- new_parent | | follows new_parent_predecessor with lag 3
- new_parent_predecessor | X |
- CHART
+ let_work_packages(<<~TABLE)
+ subject | MTWTFSS | scheduling mode | properties
+ work_package | XX | manual |
+ new_parent_predecessor | X | manual |
+ new_parent | | automatic | follows new_parent_predecessor with lag 3
+ TABLE
before do
work_package.parent = new_parent
@@ -1224,11 +1263,11 @@ RSpec.describe WorkPackages::SetScheduleService, "working days" do
end
it "does not reschedule the moved work package, and sets new parent dates to child dates" do
- expect(subject.all_results).to match_schedule(<<~CHART)
- days | MTWTFSS |
+ expect_work_packages(subject.all_results, <<~TABLE)
+ subject | MTWTFSS |
work_package | XX |
new_parent | XX |
- CHART
+ TABLE
end
end
end
diff --git a/spec/services/work_packages/update_ancestors_service_spec.rb b/spec/services/work_packages/update_ancestors_service_spec.rb
index 1590a5af0d8..d4ba6b3be44 100644
--- a/spec/services/work_packages/update_ancestors_service_spec.rb
+++ b/spec/services/work_packages/update_ancestors_service_spec.rb
@@ -1050,25 +1050,31 @@ RSpec.describe WorkPackages::UpdateAncestorsService,
describe "ignore_non_working_days propagation" do
shared_let(:grandgrandparent) do
create(:work_package,
- subject: "grandgrandparent")
+ subject: "grandgrandparent",
+ schedule_manually: false)
end
shared_let(:grandparent) do
create(:work_package,
subject: "grandparent",
- parent: grandgrandparent)
+ parent: grandgrandparent,
+ schedule_manually: false)
end
shared_let(:parent) do
create(:work_package,
subject: "parent",
- parent: grandparent)
+ parent: grandparent,
+ schedule_manually: false)
end
shared_let(:sibling) do
create(:work_package,
subject: "sibling",
+ schedule_manually: true,
parent:)
end
shared_let(:work_package) do
- create(:work_package)
+ create(:work_package,
+ subject: "main",
+ schedule_manually: true)
end
subject do
@@ -1081,8 +1087,6 @@ RSpec.describe WorkPackages::UpdateAncestorsService,
.call(%i(parent))
end
- let(:new_parent) { parent }
-
context "for the previous ancestors (parent removed)" do
let(:new_parent) { nil }
@@ -1127,13 +1131,16 @@ RSpec.describe WorkPackages::UpdateAncestorsService,
end
end
- context "for the new ancestors where the grandparent is on manual scheduling" do
+ context "for the new ancestors where the initiator is ignoring non-working days " \
+ "and the grandparent is on manual scheduling" do
+ let(:new_parent) { parent }
+
before do
- [grandgrandparent, work_package].each do |wp|
+ [work_package].each do |wp|
wp.update_column(:ignore_non_working_days, true)
end
- [grandparent, parent, sibling].each do |wp|
+ [grandgrandparent, grandparent, parent, sibling].each do |wp|
wp.update_column(:ignore_non_working_days, false)
end
@@ -1147,12 +1154,13 @@ RSpec.describe WorkPackages::UpdateAncestorsService,
.to be_success
end
- it "returns the former ancestors in the dependent results" do
+ it "returns the updated new ancestors in the dependent results where only the parent is updated" do
expect(subject.dependent_results.map(&:result))
.to contain_exactly(parent)
end
- it "sets the ignore_non_working_days property of the new ancestors" do
+ it "updates the parent's ignore_non_working_days attribute to true " \
+ "and does not propagate to the grandparent because it is manually scheduled" do
subject
expect(parent.reload.ignore_non_working_days)
@@ -1162,7 +1170,7 @@ RSpec.describe WorkPackages::UpdateAncestorsService,
.to be_falsey
expect(grandgrandparent.reload.ignore_non_working_days)
- .to be_truthy
+ .to be_falsey
expect(sibling.reload.ignore_non_working_days)
.to be_falsey
@@ -1170,6 +1178,8 @@ RSpec.describe WorkPackages::UpdateAncestorsService,
end
context "for the new ancestors where the parent is on manual scheduling" do
+ let(:new_parent) { parent }
+
before do
[grandgrandparent, grandparent, work_package].each do |wp|
wp.update_column(:ignore_non_working_days, true)
@@ -1189,22 +1199,23 @@ RSpec.describe WorkPackages::UpdateAncestorsService,
.to be_success
end
- it "returns the former ancestors in the dependent results" do
+ it "returns the updated new ancestors in the dependent results" do
expect(subject.dependent_results.map(&:result))
- .to be_empty
+ .to contain_exactly(grandparent, grandgrandparent)
end
- it "sets the ignore_non_working_days property of the new ancestors" do
+ it "sets the ignore_non_working_days property of the grand parent and grand grand parent to " \
+ "match the parent's value because it's manually scheduled and that's where inheritance chain starts" do
subject
expect(parent.reload.ignore_non_working_days)
.to be_falsey
expect(grandparent.reload.ignore_non_working_days)
- .to be_truthy
+ .to be_falsey
expect(grandgrandparent.reload.ignore_non_working_days)
- .to be_truthy
+ .to be_falsey
expect(sibling.reload.ignore_non_working_days)
.to be_falsey
diff --git a/spec/services/work_packages/update_service_integration_spec.rb b/spec/services/work_packages/update_service_integration_spec.rb
index 134dd035957..4335adb28fb 100644
--- a/spec/services/work_packages/update_service_integration_spec.rb
+++ b/spec/services/work_packages/update_service_integration_spec.rb
@@ -53,26 +53,31 @@ RSpec.describe WorkPackages::UpdateService, "integration", type: :model do
end
let(:work_package) do
create(:work_package,
- work_package_attributes)
+ subject: "initial",
+ **work_package_attributes)
end
let(:parent_work_package) do
create(:work_package,
- work_package_attributes).tap do |w|
+ subject: "parent",
+ schedule_manually: false,
+ **work_package_attributes).tap do |w|
w.children << work_package
work_package.reload
end
end
let(:grandparent_work_package) do
create(:work_package,
- work_package_attributes).tap do |w|
+ subject: "grandparent",
+ schedule_manually: false,
+ **work_package_attributes).tap do |w|
w.children << parent_work_package
end
end
let(:sibling1_attributes) do
- work_package_attributes.merge(parent: parent_work_package)
+ work_package_attributes.merge(subject: "sibling1", parent: parent_work_package)
end
let(:sibling2_attributes) do
- work_package_attributes.merge(parent: parent_work_package)
+ work_package_attributes.merge(subject: "sibling2", parent: parent_work_package)
end
let(:sibling1_work_package) do
create(:work_package,
@@ -83,16 +88,18 @@ RSpec.describe WorkPackages::UpdateService, "integration", type: :model do
sibling2_attributes)
end
let(:child_attributes) do
- work_package_attributes.merge(parent: work_package)
+ work_package_attributes.merge(subject: "child", parent: work_package)
end
let(:child_work_package) do
+ child_attributes[:parent].update_column(:schedule_manually, false)
create(:work_package,
child_attributes)
end
let(:grandchild_attributes) do
- work_package_attributes.merge(parent: child_work_package)
+ work_package_attributes.merge(subject: "grandchild", parent: child_work_package)
end
let(:grandchild_work_package) do
+ grandchild_attributes[:parent].update_column(:schedule_manually, false)
create(:work_package,
grandchild_attributes)
end
@@ -656,6 +663,7 @@ RSpec.describe WorkPackages::UpdateService, "integration", type: :model do
let(:following_attributes) do
work_package_attributes.merge(parent: following_parent_work_package,
subject: "following",
+ schedule_manually: false,
start_date: Time.zone.today + 6.days,
due_date: Time.zone.today + 20.days)
end
@@ -667,6 +675,7 @@ RSpec.describe WorkPackages::UpdateService, "integration", type: :model do
end
let(:following_parent_attributes) do
work_package_attributes.merge(subject: "following_parent",
+ schedule_manually: false,
start_date: Time.zone.today + 6.days,
due_date: Time.zone.today + 20.days)
end
@@ -677,6 +686,7 @@ RSpec.describe WorkPackages::UpdateService, "integration", type: :model do
let(:following2_attributes) do
work_package_attributes.merge(parent: following2_parent_work_package,
subject: "following2",
+ schedule_manually: false,
start_date: Time.zone.today + 21.days,
due_date: Time.zone.today + 25.days)
end
@@ -686,6 +696,7 @@ RSpec.describe WorkPackages::UpdateService, "integration", type: :model do
end
let(:following2_parent_attributes) do
work_package_attributes.merge(subject: "following2_parent",
+ schedule_manually: false,
start_date: Time.zone.today + 21.days,
due_date: Time.zone.today + 25.days)
end
@@ -698,6 +709,7 @@ RSpec.describe WorkPackages::UpdateService, "integration", type: :model do
let(:following3_attributes) do
work_package_attributes.merge(subject: "following3",
parent: following3_parent_work_package,
+ schedule_manually: false,
start_date: Time.zone.today + 26.days,
due_date: Time.zone.today + 30.days)
end
@@ -709,6 +721,7 @@ RSpec.describe WorkPackages::UpdateService, "integration", type: :model do
end
let(:following3_parent_attributes) do
work_package_attributes.merge(subject: "following3_parent",
+ schedule_manually: false,
start_date: Time.zone.today + 26.days,
due_date: Time.zone.today + 36.days)
end
@@ -719,6 +732,7 @@ RSpec.describe WorkPackages::UpdateService, "integration", type: :model do
let(:following3_sibling_attributes) do
work_package_attributes.merge(parent: following3_parent_work_package,
subject: "following3_sibling",
+ schedule_manually: false,
start_date: Time.zone.today + 32.days,
due_date: Time.zone.today + 36.days)
end
@@ -817,7 +831,7 @@ RSpec.describe WorkPackages::UpdateService, "integration", type: :model do
end
let(:parent_work_package) do
- create(:work_package, work_package_attributes)
+ create(:work_package, schedule_manually: false, **work_package_attributes)
end
let(:expected_parent_dates) do
@@ -860,6 +874,7 @@ RSpec.describe WorkPackages::UpdateService, "integration", type: :model do
author_id: user.id,
status_id: status.id,
priority:,
+ schedule_manually: false,
start_date: Time.zone.today + 3.days,
due_date: Time.zone.today + 9.days
}
@@ -896,6 +911,7 @@ RSpec.describe WorkPackages::UpdateService, "integration", type: :model do
work_package_attributes.merge(
subject: "new parent",
parent: nil,
+ schedule_manually: false,
start_date: Time.zone.today + 10.days,
due_date: Time.zone.today + 12.days
)
@@ -956,17 +972,17 @@ RSpec.describe WorkPackages::UpdateService, "integration", type: :model do
end
end
- describe "changing the parent with the parent being restricted in moving to an earlier date" do
+ describe "changing the parent with the parent having a predecessor restricting it moving to an earlier date" do
# there is actually some time between the new parent and its predecessor
let(:new_parent_attributes) do
work_package_attributes.merge(
subject: "new parent",
parent: nil,
+ schedule_manually: false,
start_date: Time.zone.today + 8.days,
due_date: Time.zone.today + 14.days
)
end
- let(:attributes) { { parent: new_parent_work_package } }
let(:new_parent_work_package) do
create(:work_package, new_parent_attributes)
end
@@ -1001,38 +1017,78 @@ RSpec.describe WorkPackages::UpdateService, "integration", type: :model do
new_parent_predecessor_work_package.reload
end
- it "reschedules the parent and the work package while adhering to the limitation imposed by the predecessor" do
- expect(subject)
- .to be_success
+ context "when the work package is automatically scheduled" do
+ let(:attributes) { { parent: new_parent_work_package, schedule_manually: false } }
- # sets the parent and adapts the dates
- # The dates are overwritten as the new parent is unable
- # to move to the dates of its new child because of the follows relation.
- work_package.reload
- expect(work_package.parent)
- .to eql new_parent_work_package
- expect(work_package.start_date)
- .to eql new_parent_predecessor_attributes[:due_date] + 1.day
- expect(work_package.due_date)
- .to eql new_parent_predecessor_attributes[:due_date] + 4.days
+ it "reschedules the parent and the work package while adhering to the limitation imposed by the predecessor" do
+ expect(subject)
+ .to be_success
- # adapts the parent's dates but adheres to its limitations
- # due to the follows relationship
- new_parent_work_package.reload
- expect(new_parent_work_package.start_date)
- .to eql new_parent_predecessor_attributes[:due_date] + 1.day
- expect(new_parent_work_package.due_date)
- .to eql new_parent_predecessor_attributes[:due_date] + 4.days
+ # sets the parent and adapts the dates
+ # The dates are overwritten as the new parent is unable
+ # to move to the dates of its new child because of the follows relation.
+ work_package.reload
+ expect(work_package.parent)
+ .to eq new_parent_work_package
+ expect(work_package.start_date)
+ .to eq new_parent_predecessor_attributes[:due_date] + 1.day
+ expect(work_package.due_date)
+ .to eq new_parent_predecessor_attributes[:due_date] + 4.days
+
+ # adapts the parent's dates but adheres to its limitations
+ # due to the follows relationship
+ new_parent_work_package.reload
+ expect(new_parent_work_package.start_date)
+ .to eq new_parent_predecessor_attributes[:due_date] + 1.day
+ expect(new_parent_work_package.due_date)
+ .to eq new_parent_predecessor_attributes[:due_date] + 4.days
+
+ # The parent's predecessor is unchanged
+ new_parent_predecessor_work_package.reload
+ expect(new_parent_predecessor_work_package.start_date)
+ .to eq new_parent_predecessor_work_package[:start_date]
+ expect(new_parent_predecessor_work_package.due_date)
+ .to eq new_parent_predecessor_work_package[:due_date]
+
+ expect(subject.all_results.uniq)
+ .to contain_exactly(work_package, new_parent_work_package)
+ end
+ end
- # leaves the parent's predecessor unchanged
- new_parent_work_package.reload
- expect(new_parent_work_package.start_date)
- .to eql new_parent_predecessor_attributes[:due_date] + 1.day
- expect(new_parent_work_package.due_date)
- .to eql new_parent_predecessor_attributes[:due_date] + 4.days
+ context "when the work package is manually scheduled" do
+ let(:attributes) { { parent: new_parent_work_package, schedule_manually: true } }
- expect(subject.all_results.uniq)
- .to contain_exactly(work_package, new_parent_work_package)
+ it "sets parent's dates to be the same as the work package despite the predecessor constraints" do
+ expect(subject)
+ .to be_success
+
+ # sets the parent and do not change the dates as it is manually scheduled
+ work_package.reload
+ expect(work_package.parent)
+ .to eq new_parent_work_package
+ expect(work_package.start_date)
+ .to eq work_package_attributes[:start_date]
+ expect(work_package.due_date)
+ .to eq work_package_attributes[:due_date]
+
+ # The parent dates are the same as its child. The follows relation is
+ # ignored as children dates always take precedence over relations.
+ new_parent_work_package.reload
+ expect(new_parent_work_package.start_date)
+ .to eq work_package_attributes[:start_date]
+ expect(new_parent_work_package.due_date)
+ .to eq work_package_attributes[:due_date]
+
+ # The parent's predecessor is unchanged
+ new_parent_predecessor_work_package.reload
+ expect(new_parent_predecessor_work_package.start_date)
+ .to eq new_parent_predecessor_work_package[:start_date]
+ expect(new_parent_predecessor_work_package.due_date)
+ .to eq new_parent_predecessor_work_package[:due_date]
+
+ expect(subject.all_results.uniq)
+ .to contain_exactly(work_package, new_parent_work_package)
+ end
end
end
@@ -1056,6 +1112,7 @@ RSpec.describe WorkPackages::UpdateService, "integration", type: :model do
author_id: user.id,
status_id: status.id,
priority:,
+ schedule_manually: false,
start_date: Time.zone.today,
due_date: Time.zone.today + 10.days }
end
@@ -1097,6 +1154,7 @@ RSpec.describe WorkPackages::UpdateService, "integration", type: :model do
expect(work_package.due_date)
.to eql work_package_attributes[:due_date]
+ # parent is rescheduled to the sibling's dates
parent_work_package.reload
expect(parent_work_package.start_date)
.to eql sibling_attributes[:start_date]
@@ -1222,12 +1280,13 @@ RSpec.describe WorkPackages::UpdateService, "integration", type: :model do
end
describe "removing an invalid parent" do
- # The parent does not have a required custom field set but will need to be touched since.
- # the dates, inherited from its children (and then the only remaining child) will have to be updated.
+ # The parent does not have a required custom field set but will need to be touched since
+ # the dates, inherited from its children (and then the only remaining child), will have to be updated.
let!(:parent) do
create(:work_package,
type: project.types.first,
project:,
+ schedule_manually: false,
start_date: Time.zone.today - 1.day,
due_date: Time.zone.today + 5.days)
end
diff --git a/spec/support/components/datepicker/work_package_datepicker.rb b/spec/support/components/datepicker/work_package_datepicker.rb
index be15ddb1279..a00c759ae77 100644
--- a/spec/support/components/datepicker/work_package_datepicker.rb
+++ b/spec/support/components/datepicker/work_package_datepicker.rb
@@ -133,12 +133,20 @@ module Components
def expect_scheduling_mode(manually)
if manually
- expect(container).to have_checked_field("scheduling", visible: :all)
+ expect_manual_scheduling_mode
else
- expect(container).to have_unchecked_field("scheduling", visible: :all)
+ expect_automatic_scheduling_mode
end
end
+ def expect_manual_scheduling_mode
+ expect(container).to have_checked_field("scheduling", visible: :all)
+ end
+
+ def expect_automatic_scheduling_mode
+ expect(container).to have_unchecked_field("scheduling", visible: :all)
+ end
+
def toggle_scheduling_mode
find("label", text: "Manual scheduling").click
end
diff --git a/spec/support/schedule_helpers/chart.rb b/spec/support/schedule_helpers/chart.rb
deleted file mode 100644
index 227b2469100..00000000000
--- a/spec/support/schedule_helpers/chart.rb
+++ /dev/null
@@ -1,263 +0,0 @@
-#-- copyright
-# OpenProject is an open source project management software.
-# Copyright (C) the OpenProject GmbH
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License version 3.
-#
-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
-# Copyright (C) 2006-2013 Jean-Philippe Lang
-# Copyright (C) 2010-2013 the ChiliProject Team
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-# See COPYRIGHT and LICENSE files for more details.
-#++
-
-module ScheduleHelpers
- # Contains work packages and relations information from a chart
- # representation, and information to render it.
- #
- # The work package information are:
- # * subject
- # * parent
- # * start_date
- # * due_date
- # * duration
- # * ignore_non_working_days
- #
- # The relations information are limited to follows relations and are retrieved
- # with +#predecessors_by_follower+
- #
- # The rendering information are:
- # * chart origin (the monday displayed in the header line)
- # * max and min date
- # * first column size
- #
- # The chart uses different symbols in the timeline to represent a work package
- # start and due dates:
- # * +X+: a day of the work package duration. The first +X+ is the start date,
- # the last +X+ is the due date.
- # * +[+: the work package start date. Can be used instead of +X+ when the work
- # package has no due date.
- # * +]+: the work package due date. Can be used instead of +X+ when the work
- # package has no start date.
- # * +_+: ignored but useful as a placeholder to highlight particular days, for
- # instance to highlight the previous dates of a work package.
- class Chart
- FIRST_CELL_TEXT = "days".freeze
- WEEK_DAYS_TEXT = "MTWTFSS".freeze
-
- attr_reader :id_column_size, :first_day, :last_day, :monday
-
- def self.for(representation)
- builder = ChartBuilder.new
- builder.parse(representation)
- end
-
- def self.from_work_packages(work_packages)
- ChartBuilder.new.use_work_packages(Array(work_packages))
- end
-
- def initialize
- self.monday = Date.current.next_occurring(:monday)
- self.id_column_size = FIRST_CELL_TEXT.length
- end
-
- # duplicates the chart with different representation properties
- def with(order: work_package_names, id_column_size: self.id_column_size, first_day: self.first_day, last_day: self.last_day)
- chart = Chart.new
- order = order.map(&:to_sym)
- extra_names = work_package_names - order
- chart.work_packages_attributes = work_packages_attributes.index_by { _1[:name] }.values_at(*(order + extra_names)).compact
- chart.monday = monday
- chart.id_column_size = id_column_size
- chart.first_day = first_day
- chart.last_day = last_day
- chart.predecessors_by_followers = predecessors_by_followers
- chart.lags_between = lags_between
- chart.parent_by_child = parent_by_child
- chart
- end
-
- # Sets the origin of the calendar, represented by +M+ on the first line (M as
- # in Monday).
- def monday=(monday)
- raise ArgumentError, "#{monday} is not a Monday" unless monday.wday == 1
-
- extend_calendar_range(monday, monday + 6.days)
- @monday = monday
- end
-
- def validate
- work_package_names.each do |follower|
- predecessors_by_follower(follower).each do |predecessor|
- unless work_package_attributes(predecessor)
- raise "unable to find predecessor #{predecessor.inspect} " \
- "in property \"follows #{predecessor}\" " \
- "for work package #{follower.inspect}"
- end
- end
- end
- end
-
- def work_packages_attributes
- @work_packages_attributes ||= []
- end
-
- def work_package_attributes(name)
- work_packages_attributes.find { |wpa| wpa[:name] == name.to_sym }
- end
-
- def work_package_names
- work_packages_attributes.pluck(:name)
- end
-
- def predecessors_by_follower(follower)
- predecessors_by_followers[follower]
- end
-
- def lag_between(predecessor:, follower:)
- lags_between.fetch([predecessor, follower])
- end
-
- def add_work_package(attributes)
- attributes[:start_date] ||= WorkPackage.column_defaults["start_date"]
- attributes[:due_date] ||= WorkPackage.column_defaults["due_date"]
- extend_calendar_range(*attributes.values_at(:start_date, :due_date))
- extend_id_column_size(*attributes.values_at(:subject))
- work_packages_attributes << attributes.merge(name: attributes[:subject].to_sym)
- end
-
- def set_duration(name, duration)
- unless duration.is_a?(Integer) && duration > 0
- raise ArgumentError, "unable to set duration for #{name}: " \
- "duration must be a positive integer (got #{duration.inspect})"
- end
- attributes = work_package_attributes(name.to_sym)
- dates_attributes = attributes.slice(:start_date, :due_date).compact
- if dates_attributes.any?(&:present?)
- raise ArgumentError, "unable to set duration for #{name}: " \
- "#{dates_attributes.keys.join(' and ')} is set"
- end
- attributes[:duration] = duration
- end
-
- def set_ignore_non_working_days(name, ignore_non_working_days)
- attributes = work_package_attributes(name.to_sym)
- attributes[:ignore_non_working_days] = ignore_non_working_days
- end
-
- def add_follows_relation(predecessor:, follower:, lag:)
- predecessors_by_follower(follower) << predecessor
- lags_between[[predecessor, follower]] = lag
- end
-
- def add_parent_relation(parent:, child:)
- parent_by_child[child] = parent
- end
-
- def parent(name)
- parent_by_child[name]
- end
-
- def to_s
- representer = ChartRepresenter.new(id_column_size:, days_column_size:)
- representer.add_row
- representer.add_cell(FIRST_CELL_TEXT)
- representer.add_cell(spaced_at(monday, WEEK_DAYS_TEXT))
- work_package_names.each do |name|
- representer.add_row
- representer.add_cell(name.to_s)
- representer.add_cell(span(work_package_attributes(name)))
- end
- representer.to_s
- end
-
- def compact_dates
- @first_day, @last_day = work_packages_attributes.pluck(:start_date, :due_date).flatten.compact.minmax
- @monday = ([@first_day, @last_day, @monday].compact.first - 1).next_occurring(:monday)
- extend_calendar_range(@monday, @monday + 6)
- self
- end
-
- protected
-
- attr_writer :work_packages_attributes,
- :id_column_size,
- :first_day,
- :last_day,
- :predecessors_by_followers,
- :lags_between,
- :parent_by_child
-
- private
-
- def extend_calendar_range(*dates)
- self.first_day = [@first_day, *dates].compact.min
- self.last_day = [@last_day, *dates].compact.max
- end
-
- def extend_id_column_size(name)
- self.id_column_size = [id_column_size, name.length].max
- end
-
- def days_column_size
- (first_day..last_day).count
- end
-
- def spaced_at(date, text)
- nb_days = date - first_day
- (" " * nb_days) + text
- end
-
- def span(attributes)
- case attributes
- in { start_date: nil, due_date: nil }
- ""
- in { start_date:, due_date: nil }
- spaced_at(start_date, "[")
- in { start_date: nil, due_date: }
- spaced_at(due_date, "]")
- in { start_date:, due_date: }
- days = days_for(attributes)
- span = (start_date..due_date).map do |date|
- days.working?(date) ? "X" : "."
- end.join
- spaced_at(start_date, span)
- end
- end
-
- def days_for(attributes)
- if attributes[:ignore_non_working_days]
- WorkPackages::Shared::AllDays.new
- else
- WorkPackages::Shared::WorkingDays.new
- end
- end
-
- def predecessors_by_followers
- @predecessors_by_followers ||= Hash.new { |h, k| h[k] = [] }
- end
-
- def lags_between
- @lags_between ||= Hash.new(0)
- end
-
- def parent_by_child
- @parent_by_child ||= {}
- end
- end
-end
diff --git a/spec/support/schedule_helpers/chart_builder.rb b/spec/support/schedule_helpers/chart_builder.rb
deleted file mode 100644
index 0eeabfe1781..00000000000
--- a/spec/support/schedule_helpers/chart_builder.rb
+++ /dev/null
@@ -1,147 +0,0 @@
-#-- copyright
-# OpenProject is an open source project management software.
-# Copyright (C) the OpenProject GmbH
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License version 3.
-#
-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
-# Copyright (C) 2006-2013 Jean-Philippe Lang
-# Copyright (C) 2010-2013 the ChiliProject Team
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-# See COPYRIGHT and LICENSE files for more details.
-#++
-
-module ScheduleHelpers
- # Builds a +Chart+ instance from a visual chart representation.
- #
- # Example:
- #
- # ChartBuilder.new.parse(<<~CHART)
- # days | MTWTFSS |
- # main | XX |
- # follower | XXX | follows main
- # start_only | [ |
- # due_only | ] |
- # no_dates | |
- # CHART
- class ChartBuilder
- attr_reader :chart
-
- def initialize
- @chart = Chart.new
- end
-
- def parse(representation)
- lines = representation.split("\n")
- header = lines.shift
- parse_header(header)
- lines.each do |line|
- parse_line(line)
- end
- chart.validate
- chart
- end
-
- def use_work_packages(work_packages)
- work_packages.each do |work_package|
- chart.add_work_package(work_package.slice(:subject, :start_date, :due_date, :ignore_non_working_days))
- end
- chart
- end
-
- private
-
- def parse_header(header)
- _, week_days = header.split(" | ", 2)
- unless week_days.include?(Chart::WEEK_DAYS_TEXT)
- raise ArgumentError,
- "First header line of schedule chart must contain #{Chart::WEEK_DAYS_TEXT} to indicate day names and have an origin"
- end
-
- @nb_days_from_origin_monday = week_days.index(Chart::WEEK_DAYS_TEXT.first)
- end
-
- def parse_line(line)
- case line
- when ""
- # noop
- when / \| /
- parse_work_package_line(line)
- else
- raise "unable to parse line #{line.inspect}"
- end
- end
-
- def parse_work_package_line(line)
- name, timespan, properties = line.split(" | ", 3)
- name.strip!
- attributes = { subject: name }
- attributes.update(parse_timespan(timespan))
- chart.add_work_package(attributes)
-
- properties.to_s.split(",").map(&:strip).each do |property|
- parse_properties(name, property)
- end
- end
-
- def parse_properties(name, property)
- case property
- when /^follows (\w+)(?: with lag (\d+))?/
- chart.add_follows_relation(
- predecessor: $1.to_sym,
- follower: name.to_sym,
- lag: $2.to_i
- )
- when /^child of (\w+)/
- chart.add_parent_relation(
- parent: $1.to_sym,
- child: name.to_sym
- )
- when /^duration (\d+)/
- chart.set_duration(name, $1.to_i)
- when /^working days work week$/
- chart.set_ignore_non_working_days(name, false)
- when /^working days include weekends$/
- chart.set_ignore_non_working_days(name, true)
- else
- spell_checker = DidYouMean::SpellChecker.new(
- dictionary: [
- "follows :wp",
- "follows :wp with lag :int",
- "child of :wp",
- "duration :int",
- "working days work week",
- "working days include weekends"
- ]
- )
- suggestions = spell_checker.correct(property).map(&:inspect).join(" ")
- did_you_mean = " Did you mean #{suggestions} instead?" if suggestions.present?
- raise "unable to parse property #{property.inspect} for line #{name.inspect}.#{did_you_mean}"
- end
- end
-
- def parse_timespan(timespan)
- start_pos = timespan.index("[") || timespan.index("X")
- due_pos = timespan.rindex("]") || timespan.rindex("X")
- {
- start_date: start_pos && (chart.monday - @nb_days_from_origin_monday + start_pos),
- due_date: due_pos && (chart.monday - @nb_days_from_origin_monday + due_pos)
- }
- end
- end
-end
diff --git a/spec/support/schedule_helpers/chart_representer.rb b/spec/support/schedule_helpers/chart_representer.rb
deleted file mode 100644
index b41545079af..00000000000
--- a/spec/support/schedule_helpers/chart_representer.rb
+++ /dev/null
@@ -1,82 +0,0 @@
-#-- copyright
-# OpenProject is an open source project management software.
-# Copyright (C) the OpenProject GmbH
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License version 3.
-#
-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
-# Copyright (C) 2006-2013 Jean-Philippe Lang
-# Copyright (C) 2010-2013 the ChiliProject Team
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-# See COPYRIGHT and LICENSE files for more details.
-#++
-
-module ScheduleHelpers
- class ChartRepresenter
- LINE = "%<id>s | %<days>s |".freeze
-
- def self.normalized_to_s(expected_chart, actual_chart)
- normalize_ignore_non_working_days_information(expected_chart, actual_chart)
- order = expected_chart.work_package_names
- id_column_size = [expected_chart, actual_chart].map(&:id_column_size).max
- first_day = [expected_chart, actual_chart].map(&:first_day).min
- last_day = [expected_chart, actual_chart].map(&:last_day).max
- [expected_chart, actual_chart]
- .map { |chart| chart.with(order:, id_column_size:, first_day:, last_day:) }
- .map(&:to_s)
- end
-
- # Define ignore_non_working_days attribute from +actual_chart+ when not
- # explicitly set in +expected_chart+.
- def self.normalize_ignore_non_working_days_information(expected_chart, actual_chart)
- expected_chart.work_packages_attributes.each do |work_package_attributes|
- next if work_package_attributes.has_key?(:ignore_non_working_days)
-
- name = work_package_attributes[:name]
- actual_attributes = actual_chart.work_package_attributes(name)
- next if actual_attributes.nil? || !actual_attributes.has_key?(:ignore_non_working_days)
-
- work_package_attributes[:ignore_non_working_days] = actual_attributes[:ignore_non_working_days]
- end
- end
-
- def initialize(id_column_size:, days_column_size:)
- @id_column_size = id_column_size
- @days_column_size = days_column_size
- end
-
- def add_row
- rows << []
- end
-
- def add_cell(text)
- rows.last << text
- end
-
- def rows
- @rows ||= []
- end
-
- def to_s
- line_template = "%<id>-#{@id_column_size}s | %<days>-#{@days_column_size}s |"
- rows.map do |row|
- line_template % { id: row[0], days: row[1] }
- end.join("\n")
- end
- end
-end
diff --git a/spec/support/schedule_helpers/example_methods.rb b/spec/support/schedule_helpers/example_methods.rb
deleted file mode 100644
index 0d96acb9334..00000000000
--- a/spec/support/schedule_helpers/example_methods.rb
+++ /dev/null
@@ -1,115 +0,0 @@
-#-- copyright
-# OpenProject is an open source project management software.
-# Copyright (C) the OpenProject GmbH
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License version 3.
-#
-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
-# Copyright (C) 2006-2013 Jean-Philippe Lang
-# Copyright (C) 2010-2013 the ChiliProject Team
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-# See COPYRIGHT and LICENSE files for more details.
-#++
-
-module ScheduleHelpers
- module ExampleMethods
- # Create work packages and relations from a visual chart representation.
- #
- # For instance:
- #
- # create_schedule(<<~CHART)
- # days | MTWTFSS |
- # main | XX |
- # follower | XXX | follows main
- # start_only | [ |
- # due_only | ] |
- # CHART
- #
- # is equivalent to:
- #
- # create(:work_package, subject: 'main', start_date: next_monday, due_date: next_monday + 1.day)
- # create(:work_package, subject: 'follower', start_date: next_monday + 2.days, due_date: next_monday + 4.days) }
- # create(:work_package, subject: 'start_only', start_date: next_monday + 1.day) }
- # create(:work_package, subject: 'due_only', due_date: next_monday + 3.days) }
- # create(:follows_relation, from: follower, to: main, lag: 0) }
- #
- def create_schedule(chart_representation)
- chart = Chart.for(chart_representation)
- ScheduleBuilder.from_chart(chart)
- end
-
- # Change the given work packages according to the given chart representation.
- # Work packages are changed without being saved.
- #
- # For instance:
- #
- # before do
- # change_schedule([main], <<~CHART)
- # days | MTWTFSS |
- # main | XX |
- # CHART
- # end
- #
- # is equivalent to:
- #
- # before do
- # main.start_date = monday
- # main.due_date = tuesday
- # end
- def change_schedule(work_packages, chart)
- Chart.for(chart).work_packages_attributes.each do |attributes|
- work_package = work_packages.find { |wp| wp.subject == attributes[:subject] }
- unless work_package
- raise ArgumentError, "no work package with subject #{attributes[:subject]} given; " \
- "available work packages are #{work_packages.pluck(:subject).to_sentence}"
- end
-
- attributes.slice(:start_date, :due_date).each do |attribute, value|
- work_package.send(:"#{attribute}=", value)
- end
- end
- end
-
- # Expect the given work packages to match a visual chart representation.
- #
- # It uses +match_schedule+ internally.
- #
- # For instance:
- #
- # it 'is scheduled' do
- # expect_schedule(work_packages, <<~CHART)
- # days | MTWTFSS |
- # main | XX |
- # follower | XXX |
- # CHART
- # end
- #
- # is equivalent to:
- #
- # it 'is scheduled' do
- # expect(work_packages).to match_schedule(<<~CHART)
- # days | MTWTFSS |
- # main | XX |
- # follower | XXX |
- # CHART
- # end
- def expect_schedule(work_packages, chart)
- expect(work_packages).to match_schedule(chart)
- end
- end
-end
diff --git a/spec/support/schedule_helpers/let_schedule.rb b/spec/support/schedule_helpers/let_schedule.rb
deleted file mode 100644
index 71e0d6ad4ea..00000000000
--- a/spec/support/schedule_helpers/let_schedule.rb
+++ /dev/null
@@ -1,74 +0,0 @@
-#-- copyright
-# OpenProject is an open source project management software.
-# Copyright (C) the OpenProject GmbH
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License version 3.
-#
-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
-# Copyright (C) 2006-2013 Jean-Philippe Lang
-# Copyright (C) 2010-2013 the ChiliProject Team
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-# See COPYRIGHT and LICENSE files for more details.
-#++
-
-module ScheduleHelpers
- module LetSchedule
- # Declare work packages and relations from a visual chart representation.
- #
- # It uses +create_schedule+ internally and is useful to have direct access
- # to the created work packages.
- #
- # For instance:
- #
- # let_schedule(<<~CHART)
- # days | MTWTFSS |
- # main | XX |
- # follower | XXX | follows main
- # start_only | [ |
- # due_only | ] |
- # CHART
- #
- # is equivalent to:
- #
- # let!(:schedule) do
- # create_schedule(chart)
- # end
- # let(:main) do
- # schedule.work_package(:main)
- # end
- # let(:follower) do
- # schedule.work_package(:follower)
- # end
- # let(:start_only) do
- # schedule.work_package(:start_only)
- # end
- # let(:due_only) do
- # schedule.work_package(:due_only)
- # end
- def let_schedule(chart_representation)
- # To be able to use `travel_to` in a before hook, the dates in the chart
- # must be lazy evaluated in a let statement.
- let!(:schedule) { create_schedule(chart_representation) }
-
- chart = Chart.for(chart_representation)
- chart.work_package_names.each do |name|
- let(name) { schedule.work_package(name) }
- end
- end
- end
-end
diff --git a/spec/support/schedule_helpers/schedule.rb b/spec/support/schedule_helpers/schedule.rb
deleted file mode 100644
index fa7767c1003..00000000000
--- a/spec/support/schedule_helpers/schedule.rb
+++ /dev/null
@@ -1,67 +0,0 @@
-#-- copyright
-# OpenProject is an open source project management software.
-# Copyright (C) the OpenProject GmbH
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License version 3.
-#
-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
-# Copyright (C) 2006-2013 Jean-Philippe Lang
-# Copyright (C) 2010-2013 the ChiliProject Team
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-# See COPYRIGHT and LICENSE files for more details.
-#++
-
-module ScheduleHelpers
- class Schedule
- def initialize(work_packages, follows_relations)
- @work_packages = work_packages
- @follows_relations = follows_relations
- end
-
- def work_package(name)
- name = normalize_name(name)
- @work_packages[name]
- end
-
- def follows_relation(from:, to:)
- from = normalize_name(from)
- to = normalize_name(to)
- @follows_relations[from:, to:]
- end
-
- def monday
- Date.current.next_occurring(:monday)
- end
-
- %i[tuesday wednesday thursday friday saturday sunday].each do |day_name|
- define_method(day_name) { monday.next_occurring(day_name) }
- end
-
- private
-
- def normalize_name(name)
- symbolic_name = name.to_sym
- return symbolic_name if @work_packages.has_key?(symbolic_name)
-
- spell_checker = DidYouMean::SpellChecker.new(dictionary: @work_packages.keys.map(&:to_s))
- suggestions = spell_checker.correct(name).map(&:inspect).join(" ")
- did_you_mean = " Did you mean #{suggestions} instead?" if suggestions.present?
- raise "No work package with name #{name.inspect} in schedule.#{did_you_mean}"
- end
- end
-end
diff --git a/spec/support/schedule_helpers/schedule_builder.rb b/spec/support/schedule_helpers/schedule_builder.rb
deleted file mode 100644
index fdb8cc95bd6..00000000000
--- a/spec/support/schedule_helpers/schedule_builder.rb
+++ /dev/null
@@ -1,74 +0,0 @@
-#-- copyright
-# OpenProject is an open source project management software.
-# Copyright (C) the OpenProject GmbH
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License version 3.
-#
-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
-# Copyright (C) 2006-2013 Jean-Philippe Lang
-# Copyright (C) 2010-2013 the ChiliProject Team
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-# See COPYRIGHT and LICENSE files for more details.
-#++
-
-module ScheduleHelpers
- class ScheduleBuilder
- def self.from_chart(chart)
- creator = new(chart)
- chart.work_package_names.each do |name|
- creator.create_work_package(name)
- creator.create_follows_relations(name)
- end
- Schedule.new(creator.work_packages, creator.follows_relations)
- end
-
- attr_reader :chart, :work_packages, :follows_relations
-
- def initialize(chart)
- @chart = chart
- @work_packages = {}
- @follows_relations = {}
- end
-
- def create_work_package(name)
- work_packages[name] ||= begin
- attributes = chart
- .work_package_attributes(name)
- .excluding(:name)
- .merge(parent: parent_of(name))
- FactoryBot.create(:work_package, attributes)
- end
- end
-
- def create_follows_relations(follower)
- chart.predecessors_by_follower(follower).each do |predecessor|
- follows_relations[{ from: follower, to: predecessor }] =
- FactoryBot.create(:follows_relation,
- from: create_work_package(follower),
- to: create_work_package(predecessor),
- lag: chart.lag_between(predecessor:, follower:))
- end
- end
-
- def parent_of(name)
- if chart.parent(name)
- create_work_package(chart.parent(name))
- end
- end
- end
-end
diff --git a/spec/support/table_helpers/column.rb b/spec/support/table_helpers/column.rb
index 2c5fb667a44..378c3786216 100644
--- a/spec/support/table_helpers/column.rb
+++ b/spec/support/table_helpers/column.rb
@@ -31,6 +31,7 @@
require_relative "identifier"
require_relative "column_type/generic"
require_relative "column_type/with_identifier_metadata"
+require_relative "column_type/days_counting"
require_relative "column_type/duration"
require_relative "column_type/hierarchy"
require_relative "column_type/percentage"
@@ -52,6 +53,7 @@ module TableHelpers
done_ratio: ColumnType::Percentage,
derived_done_ratio: ColumnType::Percentage,
hierarchy: ColumnType::Hierarchy,
+ ignore_non_working_days: ColumnType::DaysCounting,
properties: ColumnType::Properties,
schedule: ColumnType::Schedule,
schedule_manually: ColumnType::SchedulingMode,
@@ -90,6 +92,8 @@ module TableHelpers
:due_date
when /.*MTWTFSS.*/
:schedule
+ when /\s*days counting\s*/
+ :ignore_non_working_days
when /\s*scheduling mode\s*/
:schedule_manually
when /\s*properties\s*/
diff --git a/spec/support/schedule_helpers.rb b/spec/support/table_helpers/column_type/days_counting.rb
similarity index 52%
rename from spec/support/schedule_helpers.rb
rename to spec/support/table_helpers/column_type/days_counting.rb
index a39f45398ad..5f40f9f5245 100644
--- a/spec/support/schedule_helpers.rb
+++ b/spec/support/table_helpers/column_type/days_counting.rb
@@ -1,6 +1,8 @@
+# frozen_string_literal: true
+
#-- copyright
# OpenProject is an open source project management software.
-# Copyright (C) the OpenProject GmbH
+# Copyright (C) 2012-2024 the OpenProject GmbH
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License version 3.
@@ -26,23 +28,39 @@
# See COPYRIGHT and LICENSE files for more details.
#++
-Dir[Rails.root.join("spec/support/schedule_helpers/*.rb")].each { |f| require f }
-
-RSpec.configure do |config|
- config.extend ScheduleHelpers::LetSchedule
- config.include ScheduleHelpers::ExampleMethods
-
- RSpec::Matchers.define :match_schedule do |expected|
- match do |actual_work_packages|
- expected_chart = ScheduleHelpers::Chart.for(expected)
- actual_chart = ScheduleHelpers::Chart.from_work_packages(actual_work_packages)
+module TableHelpers
+ module ColumnType
+ # Column to specify how days are counted for duration.
+ #
+ # Can take values 'all days' or 'working days only' to set `ignore_non_working_days`
+ # attribute to `true` or `false` respectively.
+ #
+ # Example:
+ #
+ # | subject | days counting |
+ # | wp 1 | all days |
+ # | wp 2 | working days only |
+ class DaysCounting < Generic
+ def format(value)
+ if value
+ "all days"
+ else
+ "working days only"
+ end
+ end
- @expected, @actual = ScheduleHelpers::ChartRepresenter.normalized_to_s(expected_chart, actual_chart)
-
- values_match? @expected, @actual
+ def parse(raw_value)
+ case raw_value.downcase.strip
+ when "all days", "true"
+ true
+ when "working days only", "false"
+ false
+ else
+ raise "Invalid value for 'days counting' column: #{raw_value.strip.inspect}. " \
+ "Expected 'all days' (ignore_non_working_days: true) " \
+ "or 'working days only' (ignore_non_working_days: false)."
+ end
+ end
end
-
- diffable
- attr_reader :expected, :actual
end
end
diff --git a/spec/support/table_helpers/column_type/properties.rb b/spec/support/table_helpers/column_type/properties.rb
index dbe0e919c97..d940af695e1 100644
--- a/spec/support/table_helpers/column_type/properties.rb
+++ b/spec/support/table_helpers/column_type/properties.rb
@@ -43,7 +43,8 @@ module TableHelpers
# | follower | follows main with lag 2 |
# | follower2 | follows follower |
#
- # Adapted from original implementation in `spec/support/schedule_helpers/chart_builder.rb`.
+ # Adapted from (now deleted) original implementation
+ # in `spec/support/schedule_helpers/chart_builder.rb`.
class Properties < Generic
def attributes_for_work_package(_attribute, _work_package)
{}
diff --git a/spec/support/table_helpers/column_type/schedule.rb b/spec/support/table_helpers/column_type/schedule.rb
index 07269136537..5abe95ce5b2 100644
--- a/spec/support/table_helpers/column_type/schedule.rb
+++ b/spec/support/table_helpers/column_type/schedule.rb
@@ -52,7 +52,8 @@ module TableHelpers
# | due date only | ] |
# | no dates | |
#
- # Adapted from original implementation in `spec/support/schedule_helpers/chart_builder.rb`.
+ # Adapted from (now deleted) original implementation
+ # in `spec/support/schedule_helpers/chart_builder.rb`.
class Schedule < Generic
def attributes_for_work_package(_attribute, work_package)
{
diff --git a/spec/support/table_helpers/example_methods.rb b/spec/support/table_helpers/example_methods.rb
index e55c693a035..b9286e5ab27 100644
--- a/spec/support/table_helpers/example_methods.rb
+++ b/spec/support/table_helpers/example_methods.rb
@@ -49,6 +49,42 @@ module TableHelpers
table_data.create_work_packages
end
+ # Change the given work packages according to the given table representation.
+ # Work packages are changed without being saved.
+ #
+ # The first column gives the identifier of the work package to update, so it
+ # cannot be used to update the subject or the hierarchy.
+ #
+ # For instance:
+ #
+ # before do
+ # update_work_packages([main], <<~TABLE)
+ # subject | MTWTFSS | scheduling mode |
+ # main | XX | manual |
+ # TABLE
+ # end
+ #
+ # is equivalent to:
+ #
+ # before do
+ # main.start_date = monday
+ # main.due_date = tuesday
+ # main.schedule_manually = true
+ # end
+ def change_work_packages(work_packages, table_representation)
+ TableData.for(table_representation).work_packages_data.pluck(:attributes).each do |attributes|
+ work_package = work_packages.find { |wp| wp.subject == attributes[:subject] }
+ unless work_package
+ raise ArgumentError, "no work package with subject #{attributes[:subject]} given; " \
+ "available work packages are #{work_packages.pluck(:subject).to_sentence}"
+ end
+
+ attributes.without(:subject).each do |attribute, value|
+ work_package.send(:"#{attribute}=", value)
+ end
+ end
+ end
+
# Expect the given work packages to match a visual table representation.
#
# It uses +match_table+ internally. It does not reload the work packages
diff --git a/spec/support/table_helpers/table.rb b/spec/support/table_helpers/table.rb
index 7ad26d05076..d31a1e0debb 100644
--- a/spec/support/table_helpers/table.rb
+++ b/spec/support/table_helpers/table.rb
@@ -42,6 +42,10 @@ module TableHelpers
@work_packages_by_identifier.values
end
+ def relation(successor:)
+ @relations.find { |relation| relation.follows? && relation.from.subject == successor }
+ end
+
def relations
@relations
end
diff --git a/spec/support_spec/schedule_helpers/chart_builder_spec.rb b/spec/support_spec/schedule_helpers/chart_builder_spec.rb
deleted file mode 100644
index b2992159629..00000000000
--- a/spec/support_spec/schedule_helpers/chart_builder_spec.rb
+++ /dev/null
@@ -1,189 +0,0 @@
-#-- copyright
-# OpenProject is an open source project management software.
-# Copyright (C) the OpenProject GmbH
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License version 3.
-#
-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
-# Copyright (C) 2006-2013 Jean-Philippe Lang
-# Copyright (C) 2010-2013 the ChiliProject Team
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-# See COPYRIGHT and LICENSE files for more details.
-#++
-
-require "spec_helper"
-
-RSpec.describe ScheduleHelpers::ChartBuilder do
- let(:fake_today) { Date.new(2022, 6, 16) } # Thursday 16 June 2022
- let(:monday) { Date.new(2022, 6, 20) } # Monday 20 June
- let(:tuesday) { Date.new(2022, 6, 21) }
- let(:wednesday) { Date.new(2022, 6, 22) }
- let(:thursday) { Date.new(2022, 6, 23) }
- let(:friday) { Date.new(2022, 6, 24) }
- let(:saturday) { Date.new(2022, 6, 25) }
- let(:sunday) { Date.new(2022, 6, 26) }
-
- subject(:builder) { described_class.new }
-
- describe "happy path" do
- let(:next_tuesday) { tuesday + 7.days }
-
- before do
- travel_to(fake_today)
- end
-
- it "reads a chart and convert it into objects with attributes" do
- chart = builder.parse(<<~CHART)
- days | MTWTFSS |
- main | XX |
- other | XX..XX |
- follower | XXX | follows main
- start_only | [ |
- due_only | ] |
- no_dates | |
- CHART
- expect(chart.work_packages_attributes).to eq(
- [
- { name: :main, subject: "main", start_date: monday, due_date: tuesday },
- { name: :other, subject: "other", start_date: thursday, due_date: next_tuesday },
- { name: :follower, subject: "follower", start_date: wednesday, due_date: friday },
- { name: :start_only, subject: "start_only", start_date: tuesday, due_date: nil },
- { name: :due_only, subject: "due_only", start_date: nil, due_date: friday },
- { name: :no_dates, subject: "no_dates", start_date: nil, due_date: nil }
- ]
- )
- expect(chart.predecessors_by_follower(:main)).to eq([])
- expect(chart.predecessors_by_follower(:other)).to eq([])
- expect(chart.predecessors_by_follower(:follower)).to eq([:main])
- end
- end
-
- describe "origin day" do
- before do
- travel_to(fake_today)
- end
-
- it "is identified by the M in MTWTFSS and corresponds to next monday" do
- chart = builder.parse(<<~CHART)
- days | MTWTFSS |
- CHART
- expect(chart.monday).to eq(monday)
- expect(chart.monday).to eq(chart.first_day)
- end
-
- it "is not identified by mtwtfss which can be used as documentation instead" do
- chart = builder.parse(<<~CHART)
- days | mtwtfssMTWTFSSmtwtfss |
- wp | X |
- CHART
- expect(chart.monday).to eq(monday)
- expect(chart.first_day).to eq(chart.work_package_attributes(:wp)[:start_date])
- end
- end
-
- describe "properties" do
- describe "follows <name>" do
- it "adds a follows relation to the named" do
- chart = builder.parse(<<~CHART)
- days | MTWTFSS |
- main | |
- follower | | follows main
- CHART
- expect(chart.predecessors_by_follower(:follower)).to eq([:main])
- expect(chart.lag_between(predecessor: :main, follower: :follower)).to eq(0)
- end
-
- it "can be declared in any order" do
- chart = builder.parse(<<~CHART)
- days | MTWTFSS |
- follower | | follows main
- main | |
- CHART
- expect(chart.predecessors_by_follower(:follower)).to eq([:main])
- expect(chart.lag_between(predecessor: :main, follower: :follower)).to eq(0)
- end
- end
-
- describe "follows <name> with lag <n>" do
- it "adds a follows relation to the named with a lag" do
- chart = builder.parse(<<~CHART)
- days | MTWTFSS |
- main | |
- follower | | follows main with lag 3
- CHART
- expect(chart.predecessors_by_follower(:follower)).to eq([:main])
- expect(chart.lag_between(predecessor: :main, follower: :follower)).to eq(3)
- end
- end
-
- describe "child of <name>" do
- it "sets the parent to the named one" do
- chart = builder.parse(<<~CHART)
- days | MTWTFSS |
- parent | | child of grandparent
- main | | child of parent
- grandparent | |
- CHART
- expect(chart.parent(:grandparent)).to be_nil
- expect(chart.parent(:parent)).to eq(:grandparent)
- expect(chart.parent(:main)).to eq(:parent)
- end
- end
-
- describe "duration <int>" do
- it "sets the duration of the work package" do
- chart = builder.parse(<<~CHART)
- days | MTWTFSS |
- main | | duration 3
- CHART
- expect(chart.work_package_attributes(:main)).to include(duration: 3)
- end
- end
-
- describe "working days work week" do
- it "sets ignore_non_working_days to false for the work package" do
- chart = builder.parse(<<~CHART)
- days | MTWTFSS |
- main | | working days work week
- CHART
- expect(chart.work_package_attributes(:main)).to include(ignore_non_working_days: false)
- end
- end
-
- describe "working days include weekends" do
- it "sets ignore_non_working_days to true for the work package" do
- chart = builder.parse(<<~CHART)
- days | MTWTFSS |
- main | | working days include weekends
- CHART
- expect(chart.work_package_attributes(:main)).to include(ignore_non_working_days: true)
- end
- end
- end
-
- describe "error handling" do
- it "raises an error if the relation references a non-existing work package predecessor" do
- expect do
- builder.parse(<<~CHART)
- | MTWTFSS |
- follower | XX | follows main
- CHART
- end.to raise_error(RuntimeError, /unable to find predecessor :main in property "follows main" for work package :follower/)
- end
- end
-end
diff --git a/spec/support_spec/schedule_helpers/chart_representer_spec.rb b/spec/support_spec/schedule_helpers/chart_representer_spec.rb
deleted file mode 100644
index 2a7f003ee65..00000000000
--- a/spec/support_spec/schedule_helpers/chart_representer_spec.rb
+++ /dev/null
@@ -1,269 +0,0 @@
-#-- copyright
-# OpenProject is an open source project management software.
-# Copyright (C) the OpenProject GmbH
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License version 3.
-#
-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
-# Copyright (C) 2006-2013 Jean-Philippe Lang
-# Copyright (C) 2010-2013 the ChiliProject Team
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-# See COPYRIGHT and LICENSE files for more details.
-#++
-
-require "spec_helper"
-
-RSpec.describe ScheduleHelpers::ChartRepresenter do
- describe "#normalized_to_s" do
- shared_let(:week_days) { week_with_saturday_and_sunday_as_weekend }
-
- context "when both charts have different work packages items and/or order" do
- def to_first_columns(charts)
- charts.map { _1.split("\n").map(&:split).map(&:first).join(" ") }
- end
-
- it "returns charts ascii with work packages in same order as the first given chart" do
- initial_expected_chart =
- ScheduleHelpers::ChartBuilder.new.parse(<<~CHART)
- days | MTWTFSS |
- main | X..X |
- other | XXX..X |
- CHART
- initial_actual_chart =
- ScheduleHelpers::ChartBuilder.new.parse(<<~CHART)
- days | MTWTFSS |
- other | XXX..X |
- main | X..X |
- CHART
-
- expected_column, actual_column =
- described_class
- .normalized_to_s(initial_expected_chart, initial_actual_chart)
- .then(&method(:to_first_columns))
-
- expect(actual_column).to eq(expected_column)
- end
-
- it "pushes extra elements of the second chart at the end" do
- initial_expected_chart =
- ScheduleHelpers::ChartBuilder.new.parse(<<~CHART)
- days | MTWTFSS |
- main | X..X |
- other | XXX..X |
- CHART
- initial_actual_chart =
- ScheduleHelpers::ChartBuilder.new.parse(<<~CHART)
- days | MTWTFSS |
- extra | |
- main | X..X |
- other | XXX..X |
- CHART
-
- expected_column, actual_column =
- described_class
- .normalized_to_s(initial_expected_chart, initial_actual_chart)
- .then(&method(:to_first_columns))
-
- expect(expected_column).to eq("days main other")
- expect(actual_column).to eq("days main other extra")
- end
-
- it "keeps extra elements of the first chart at the same place" do
- initial_expected_chart =
- ScheduleHelpers::ChartBuilder.new.parse(<<~CHART)
- days | MTWTFSS |
- main | X..X |
- extra | |
- other | XXX..X |
- CHART
- initial_actual_chart =
- ScheduleHelpers::ChartBuilder.new.parse(<<~CHART)
- days | MTWTFSS |
- main | X..X |
- other | XXX..X |
- CHART
-
- expected_column, actual_column =
- described_class
- .normalized_to_s(initial_expected_chart, initial_actual_chart)
- .then(&method(:to_first_columns))
-
- expect(expected_column).to eq("days main extra other")
- expect(actual_column).to eq("days main other")
- end
- end
-
- context "when both charts have different first column width" do
- def to_first_cells(charts)
- charts.map { _1.split("\n").first.split(" | ").first }
- end
-
- it "returns charts ascii with identical first column width" do
- tiny_chart =
- ScheduleHelpers::ChartBuilder.new.parse(<<~CHART)
- days | MTWTFSS |
- tiny name | XX |
- CHART
- longer_chart =
- ScheduleHelpers::ChartBuilder.new.parse(<<~CHART)
- days | MTWTFSS |
- much longer name | XX |
- CHART
-
- # tiny_chart as reference chart
- first_cell, second_cell =
- described_class
- .normalized_to_s(tiny_chart, longer_chart)
- .then(&method(:to_first_cells))
-
- expect(first_cell).to eq("days ")
- expect(first_cell).to eq(second_cell)
-
- # tiny_chart as reference chart
- first_cell, second_cell =
- described_class
- .normalized_to_s(longer_chart, tiny_chart)
- .then(&method(:to_first_cells))
-
- expect(first_cell).to eq("days ")
- expect(first_cell).to eq(second_cell)
- end
- end
-
- context "when both charts cover different time periods" do
- def to_headers(charts)
- charts.map { _1.split("\n").first }
- end
-
- it "returns charts ascii with identical time periods" do
- larger_chart =
- ScheduleHelpers::ChartBuilder.new.parse(<<~CHART)
- days | MTWTFSS |
- main | XXXXXXXXXXX |
- CHART
- shorter_chart =
- ScheduleHelpers::ChartBuilder.new.parse(<<~CHART)
- days | MTWTFSS |
- main | XXX |
- CHART
-
- # larger_chart as reference
- first_header, second_header =
- described_class
- .normalized_to_s(larger_chart, shorter_chart)
- .then(&method(:to_headers))
-
- expect(first_header).to eq(second_header)
-
- # shorter_chart as reference
- first_header, second_header =
- described_class
- .normalized_to_s(shorter_chart, larger_chart)
- .then(&method(:to_headers))
-
- expect(first_header).to eq(second_header)
- end
- end
-
- context "when expected chart does not have working days information" do
- def to_headers(charts)
- charts.map { _1.split("\n").first }
- end
-
- it "gets it from actual chart information" do
- # in real tests, actual will probably be created from WorkPackage instances
- actual_chart =
- ScheduleHelpers::ChartBuilder.new.parse(<<~CHART)
- days | MTWTFSS |
- main | XXXXX | working days include weekends
- other | X..X | working days work week
- CHART
- expected_chart =
- ScheduleHelpers::ChartBuilder.new.parse(<<~CHART)
- days | MTWTFSS |
- main | XXXXX |
- other | X..X |
- CHART
-
- normalized_expected, normalized_actual =
- described_class
- .normalized_to_s(expected_chart, actual_chart)
-
- expect(normalized_actual).to eq(normalized_expected)
- end
-
- it "ignores working days information for extra work packages not defined in actual" do
- initial_actual_chart =
- ScheduleHelpers::ChartBuilder.new.parse(<<~CHART)
- days | MTWTFSS |
- main | X..X |
- CHART
- initial_expected_chart =
- ScheduleHelpers::ChartBuilder.new.parse(<<~CHART)
- days | MTWTFSS |
- main | X..X |
- extra | |
- CHART
-
- expect { described_class.normalized_to_s(initial_expected_chart, initial_actual_chart) }
- .not_to raise_error
- end
- end
-
- context "when expected chart has different working days information from actual" do
- def to_headers(charts)
- charts.map { _1.split("\n").first }
- end
-
- it "use each information from each side" do
- # in real tests, actual will probably be created from WorkPackage instances
- actual_chart =
- ScheduleHelpers::ChartBuilder.new.parse(<<~CHART)
- days | MTWTFSS |
- main | XXXXXXXX | working days include weekends
- other | X..X | working days work week
- foo | X..X |
- CHART
- expected_chart =
- ScheduleHelpers::ChartBuilder.new.parse(<<~CHART)
- days | MTWTFSS |
- main | XXXXX..X | working days work week
- other | XXXX | working days include weekends
- foo | X..X |
- CHART
-
- normalized_expected, normalized_actual =
- described_class
- .normalized_to_s(expected_chart, actual_chart)
-
- expect(normalized_actual).to eq(<<~CHART.strip)
- days | MTWTFSS |
- main | XXXXXXXX |
- other | X..X |
- foo | X..X |
- CHART
- expect(normalized_expected).to eq(<<~CHART.strip)
- days | MTWTFSS |
- main | XXXXX..X |
- other | XXXX |
- foo | X..X |
- CHART
- end
- end
- end
-end
diff --git a/spec/support_spec/schedule_helpers/chart_spec.rb b/spec/support_spec/schedule_helpers/chart_spec.rb
deleted file mode 100644
index aa7d42434fd..00000000000
--- a/spec/support_spec/schedule_helpers/chart_spec.rb
+++ /dev/null
@@ -1,249 +0,0 @@
-#-- copyright
-# OpenProject is an open source project management software.
-# Copyright (C) the OpenProject GmbH
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License version 3.
-#
-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
-# Copyright (C) 2006-2013 Jean-Philippe Lang
-# Copyright (C) 2010-2013 the ChiliProject Team
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-# See COPYRIGHT and LICENSE files for more details.
-#++
-
-require "spec_helper"
-
-RSpec.describe ScheduleHelpers::Chart do
- let(:fake_today) { Date.new(2022, 6, 16) } # Thursday 16 June 2022
- let(:monday) { Date.new(2022, 6, 20) } # Monday 20 June
- let(:tuesday) { Date.new(2022, 6, 21) }
- let(:wednesday) { Date.new(2022, 6, 22) }
- let(:thursday) { Date.new(2022, 6, 23) }
- let(:friday) { Date.new(2022, 6, 24) }
- let(:saturday) { Date.new(2022, 6, 25) }
- let(:sunday) { Date.new(2022, 6, 26) }
-
- subject(:chart) { described_class.new }
-
- before do
- travel_to(fake_today)
- end
-
- describe "#first_day" do
- it "returns the first day represented on the graph, which is next Monday" do
- expect(chart.first_day).to eq(monday)
- end
-
- it "can be set to an earlier date by setting the origin monday to an earlier date" do
- expect(chart.first_day).to eq(monday)
-
- # no change when origin is moved forward
- expect { chart.monday = monday + 14.days }
- .not_to change(chart, :first_day)
-
- # change when origin is moved backward
- expect { chart.monday = monday - 14.days }
- .to change(chart, :first_day).to(monday - 14.days)
- end
-
- context "with work packages" do
- it "returns the minimum between work packages dates and origin Monday" do
- expect(chart.first_day).to eq(monday)
-
- chart.add_work_package(subject: "wp1", start_date: tuesday)
- expect(chart.first_day).to eq(monday)
-
- chart.add_work_package(subject: "wp2", start_date: monday - 3.days)
- expect(chart.first_day).to eq(monday - 3.days)
-
- chart.add_work_package(subject: "wp3", start_date: sunday)
- expect(chart.first_day).to eq(monday - 3.days)
-
- chart.add_work_package(subject: "wp4", due_date: monday - 6.days)
- expect(chart.first_day).to eq(monday - 6.days)
- end
- end
- end
-
- describe "#last_day" do
- it "returns the last day represented on the graph, which is the Sunday following origin Monday" do
- expect(chart.last_day).to eq(sunday)
- end
-
- it "can be set to an later date by setting the origin Monday to a later date" do
- expect(chart.last_day).to eq(sunday)
-
- # no change when origin is moved backward
- expect { chart.monday = monday - 14.days }
- .not_to change(chart, :last_day)
-
- # change when origin is moved forward
- expect { chart.monday = monday + 14.days }
- .to change(chart, :last_day).to(sunday + 14.days)
- end
-
- context "with work packages" do
- it "returns the maximum between work packages dates and the Sunday following origin Monday" do
- expect(chart.last_day).to eq(sunday)
-
- chart.add_work_package(subject: "wp1", due_date: tuesday + 7.days)
- expect(chart.last_day).to eq(tuesday + 7.days)
-
- chart.add_work_package(subject: "wp2", start_date: monday - 3.days)
- expect(chart.last_day).to eq(tuesday + 7.days)
-
- chart.add_work_package(subject: "wp3", start_date: monday + 20.days)
- expect(chart.last_day).to eq(monday + 20.days)
- end
- end
- end
-
- describe "#compact_dates" do
- it "makes the chart dates fit with the work packages dates" do
- chart.add_work_package(subject: "wp1", start_date: friday - 21.days, due_date: tuesday - 14.days)
- chart.add_work_package(subject: "wp2", start_date: wednesday - 14.days)
- chart.add_work_package(subject: "wp3", due_date: thursday - 14.days)
- chart.add_work_package(subject: "wp4", due_date: thursday - 14.days)
-
- expect { chart.compact_dates }
- .to change { [chart.monday, chart.first_day, chart.last_day] }
- .from([monday, friday - 21.days, sunday])
- .to([monday - 14.days, friday - 21.days, sunday - 14.days])
- end
-
- it "does nothing if there are no work packages" do
- expect { chart.compact_dates }
- .not_to change { [chart.monday, chart.first_day, chart.last_day] }
- end
-
- it "does nothing if none of the work packages have any dates" do
- chart.add_work_package(subject: "wp1")
- chart.add_work_package(subject: "wp2")
- chart.add_work_package(subject: "wp3")
-
- expect { chart.compact_dates }
- .not_to change { [chart.monday, chart.first_day, chart.last_day] }
- end
- end
-
- describe "#set_duration" do
- it "sets the duration for a work package" do
- chart.add_work_package(subject: "wp")
- chart.set_duration("wp", 3)
- expect(chart.work_package_attributes("wp")).to include(duration: 3)
- end
-
- it "must set the duration to a positive integer" do
- chart.add_work_package(subject: "wp")
- expect { chart.set_duration("wp", 0) }
- .to raise_error(ArgumentError, "unable to set duration for wp: duration must be a positive integer (got 0)")
-
- expect { chart.set_duration("wp", -5) }
- .to raise_error(ArgumentError, "unable to set duration for wp: duration must be a positive integer (got -5)")
-
- expect { chart.set_duration("wp", "hello") }
- .to raise_error(ArgumentError, 'unable to set duration for wp: duration must be a positive integer (got "hello")')
-
- expect { chart.set_duration("wp", "42") }
- .to raise_error(ArgumentError, 'unable to set duration for wp: duration must be a positive integer (got "42")')
- end
-
- it "cannot set the duration if the work package has dates" do
- chart.add_work_package(subject: "wp_start", start_date: monday)
- expect { chart.set_duration("wp_start", 3) }
- .to raise_error(ArgumentError, "unable to set duration for wp_start: start_date is set")
-
- chart.add_work_package(subject: "wp_due", due_date: monday)
- expect { chart.set_duration("wp_due", 3) }
- .to raise_error(ArgumentError, "unable to set duration for wp_due: due_date is set")
-
- chart.add_work_package(subject: "wp_both", start_date: monday, due_date: monday)
- expect { chart.set_duration("wp_both", 3) }
- .to raise_error(ArgumentError, "unable to set duration for wp_both: start_date and due_date is set")
- end
- end
-
- describe "#to_s" do
- shared_let(:week_days) { week_with_saturday_and_sunday_as_weekend }
-
- context "with a chart built from ascii representation" do
- let(:chart) do
- ScheduleHelpers::ChartBuilder.new.parse(<<~CHART)
- days | MTWTFSS |
- main | X..X |
- other | XXX..X |
- follower | XXX | follows main
- start_only | [ |
- due_only | ] |
- no_dates | |
- CHART
- end
-
- it "returns the same ascii representation without properties information" do
- expect(chart.to_s).to eq(<<~CHART.chomp)
- days | MTWTFSS |
- main | X..X |
- other | XXX..X |
- follower | XXX |
- start_only | [ |
- due_only | ] |
- no_dates | |
- CHART
- end
- end
-
- context "with a chart built from real work packages" do
- let(:work_package1) { build_stubbed(:work_package, subject: "main", start_date: monday, due_date: tuesday) }
- let(:work_package2) do
- build_stubbed(:work_package, subject: "working_days", ignore_non_working_days: false,
- start_date: tuesday, due_date: monday + 7.days)
- end
- let(:work_package2bis) do
- build_stubbed(:work_package, subject: "all_days", ignore_non_working_days: true,
- start_date: tuesday, due_date: monday + 7.days)
- end
- let(:work_package3) { build_stubbed(:work_package, subject: "start_only", start_date: monday - 3.days) }
- let(:work_package4) { build_stubbed(:work_package, subject: "due_only", due_date: wednesday) }
- let(:work_package5) { build_stubbed(:work_package, subject: "no_dates") }
- let(:chart) do
- ScheduleHelpers::ChartBuilder.new.use_work_packages(
- [
- work_package1,
- work_package2,
- work_package2bis,
- work_package3,
- work_package4,
- work_package5
- ]
- )
- end
-
- it "returns the same ascii representation without properties information" do
- expect(chart.to_s).to eq(<<~CHART.chomp)
- days | MTWTFSS |
- main | XX |
- working_days | XXXX..X |
- all_days | XXXXXXX |
- start_only | [ |
- due_only | ] |
- no_dates | |
- CHART
- end
- end
- end
-end
diff --git a/spec/support_spec/schedule_helpers/example_methods_spec.rb b/spec/support_spec/schedule_helpers/example_methods_spec.rb
deleted file mode 100644
index 23c3f2b4a52..00000000000
--- a/spec/support_spec/schedule_helpers/example_methods_spec.rb
+++ /dev/null
@@ -1,190 +0,0 @@
-#-- copyright
-# OpenProject is an open source project management software.
-# Copyright (C) the OpenProject GmbH
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License version 3.
-#
-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
-# Copyright (C) 2006-2013 Jean-Philippe Lang
-# Copyright (C) 2010-2013 the ChiliProject Team
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-# See COPYRIGHT and LICENSE files for more details.
-#++
-
-require "spec_helper"
-
-RSpec.describe ScheduleHelpers::ExampleMethods do
- create_shared_association_defaults_for_work_package_factory
-
- describe "create_schedule" do
- let(:monday) { Date.current.next_occurring(:monday) }
- let(:tuesday) { monday + 1.day }
-
- # rubocop:disable RSpec/ExampleLength
- it "creates work packages from the given chart" do
- schedule = create_schedule(<<~CHART)
- days | MTWTFSS |
- main | XX |
- start_only | [ |
- due_only | ] |
- no_dates | |
- CHART
-
- expect(WorkPackage.count).to eq(4)
- expect(schedule.work_package("main")).to have_attributes(
- subject: "main",
- start_date: monday,
- due_date: tuesday,
- duration: 2
- )
- expect(schedule.work_package("start_only")).to have_attributes(
- subject: "start_only",
- start_date: monday,
- due_date: nil,
- duration: nil
- )
- expect(schedule.work_package("due_only")).to have_attributes(
- subject: "due_only",
- start_date: nil,
- due_date: tuesday,
- duration: nil
- )
- expect(schedule.work_package("no_dates")).to have_attributes(
- subject: "no_dates",
- start_date: nil,
- due_date: nil,
- duration: nil
- )
- end
- # rubocop:enable RSpec/ExampleLength
-
- it "creates parent/child relations from the given chart" do
- schedule = create_schedule(<<~CHART)
- days | MTWTFSS |
- main | |
- child | | child of main
- CHART
- expect(schedule.work_package("main")).to have_attributes(
- children: [schedule.work_package("child")]
- )
- expect(schedule.work_package("child")).to have_attributes(
- parent: schedule.work_package("main")
- )
- end
-
- it "creates follows relations from the given chart" do
- schedule = create_schedule(<<~CHART)
- days | MTWTFSS |
- predecessor | XX |
- follower | X | follows predecessor with lag 2
- CHART
- expect(Relation.count).to eq(1)
- expect(schedule.follows_relation(from: "follower", to: "predecessor")).to be_an_instance_of(Relation)
- expect(schedule.follows_relation(from: "follower", to: "predecessor")).to have_attributes(
- relation_type: "follows",
- lag: 2,
- from: schedule.work_package("follower"),
- to: schedule.work_package("predecessor")
- )
- end
- end
-
- describe "change_schedule" do
- let(:fake_today) { Date.new(2022, 6, 16) } # Thursday 16 June 2022
- let(:monday) { Date.new(2022, 6, 20) } # Monday 20 June
- let(:tuesday) { Date.new(2022, 6, 21) }
- let(:thursday) { Date.new(2022, 6, 23) }
- let(:friday) { Date.new(2022, 6, 24) }
-
- before do
- travel_to(fake_today)
- end
-
- it "applies dates changes to a group of work packages from a visual chart representation" do
- main = build_stubbed(:work_package, subject: "main")
- second = build_stubbed(:work_package, subject: "second")
- change_schedule([main, second], <<~CHART)
- days | MTWTFSS |
- main | XX |
- second | XX |
- CHART
- expect(main.start_date).to eq(monday)
- expect(main.due_date).to eq(tuesday)
- expect(second.start_date).to eq(thursday)
- expect(second.due_date).to eq(friday)
- end
-
- it "does not save changes" do
- main = create(:work_package, subject: "main")
- expect(main.persisted?).to be(true)
- expect(main.has_changes_to_save?).to be(false)
- change_schedule([main], <<~CHART)
- days | MTWTFSS |
- main | XX |
- CHART
- expect(main.has_changes_to_save?).to be(true)
- expect(main.changes).to eq("start_date" => [nil, monday], "due_date" => [nil, tuesday])
- end
- end
-
- describe "expect_schedule" do
- let_schedule(<<~CHART)
- | MTWTFSS |
- main | XX |
- other | XXX |
- CHART
-
- it "checks the work packages properties according to the given work packages and chart representation" do
- expect do
- expect_schedule([main, other], <<~CHART)
- | MTWTFSS |
- main | XX |
- other | XXX |
- CHART
- end.not_to raise_error
- end
-
- it "raises an error if start_date is wrong" do
- expect do
- expect_schedule([main], <<~CHART)
- | MTWTFSS |
- main | X |
- CHART
- end.to raise_error(RSpec::Expectations::ExpectationNotMetError)
- end
-
- it "raises an error if due_date is wrong" do
- expect do
- expect_schedule([main], <<~CHART)
- | MTWTFSS |
- main | XXXXX |
- CHART
- end.to raise_error(RSpec::Expectations::ExpectationNotMetError)
- end
-
- it "raises an error if a work package name in the chart cannot be found in the given work packages" do
- expect do
- expect_schedule([main], <<~CHART)
- | MTWTFSS |
- main | XX |
- other | XXXX |
- CHART
- end.to raise_error(RSpec::Expectations::ExpectationNotMetError)
- end
- end
-end
diff --git a/spec/support_spec/schedule_helpers/let_schedule_spec.rb b/spec/support_spec/schedule_helpers/let_schedule_spec.rb
deleted file mode 100644
index d6a6f69372e..00000000000
--- a/spec/support_spec/schedule_helpers/let_schedule_spec.rb
+++ /dev/null
@@ -1,71 +0,0 @@
-#-- copyright
-# OpenProject is an open source project management software.
-# Copyright (C) the OpenProject GmbH
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License version 3.
-#
-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
-# Copyright (C) 2006-2013 Jean-Philippe Lang
-# Copyright (C) 2010-2013 the ChiliProject Team
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-# See COPYRIGHT and LICENSE files for more details.
-#++
-
-require "spec_helper"
-
-RSpec.describe ScheduleHelpers::LetSchedule do
- create_shared_association_defaults_for_work_package_factory
-
- describe "let_schedule" do
- let_schedule(<<~CHART)
- days | MTWTFSS |
- main | XX |
- follower | XXX | follows main with lag 2
- child | | child of main
- CHART
-
- it "creates let calls for each work package" do
- expect([main, follower, child]).to all(be_an_instance_of(WorkPackage))
- expect([main, follower, child]).to all(be_persisted)
- expect(main).to have_attributes(
- subject: "main",
- start_date: schedule.monday,
- due_date: schedule.tuesday
- )
- expect(follower).to have_attributes(
- subject: "follower",
- start_date: schedule.wednesday,
- due_date: schedule.friday
- )
- expect(child).to have_attributes(
- subject: "child",
- start_date: nil,
- due_date: nil
- )
- end
-
- it "creates follows relations between work packages" do
- expect(follower.follows_relations.count).to eq(1)
- expect(follower.follows_relations.first.to).to eq(main)
- end
-
- it "creates parent / child relations" do
- expect(child.parent).to eq(main)
- end
- end
-end
diff --git a/spec/support_spec/table_helpers/column_type/days_counting_spec.rb b/spec/support_spec/table_helpers/column_type/days_counting_spec.rb
new file mode 100644
index 00000000000..d80fd10fdef
--- /dev/null
+++ b/spec/support_spec/table_helpers/column_type/days_counting_spec.rb
@@ -0,0 +1,99 @@
+# frozen_string_literal: true
+
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2024 the OpenProject GmbH
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License version 3.
+#
+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
+# Copyright (C) 2006-2013 Jean-Philippe Lang
+# Copyright (C) 2010-2013 the ChiliProject Team
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# See COPYRIGHT and LICENSE files for more details.
+#++
+
+require "spec_helper"
+
+module TableHelpers::ColumnType
+ RSpec.describe DaysCounting do
+ subject(:column_type) { described_class.new }
+
+ def parsed_attributes(table)
+ work_packages_data = TableHelpers::TableParser.new.parse(table)
+ work_packages_data.pluck(:attributes)
+ end
+
+ describe "#parse" do
+ it "maps 'all days' to `ignore_non_working_days: true`" do
+ expect(parsed_attributes(<<~TABLE))
+ | days counting |
+ | all days |
+ TABLE
+ .to eq([{ ignore_non_working_days: true }])
+ end
+
+ it "maps 'working days only' to `ignore_non_working_days: false`" do
+ expect(parsed_attributes(<<~TABLE))
+ | days counting |
+ | working days only |
+ TABLE
+ .to eq([{ ignore_non_working_days: false }])
+ end
+
+ it "raises an error if value is empty" do
+ expect { parsed_attributes(<<~TABLE) }
+ | days counting |
+ | |
+ TABLE
+ .to raise_error("Invalid value for 'days counting' column: \"\". " \
+ "Expected 'all days' (ignore_non_working_days: true) " \
+ "or 'working days only' (ignore_non_working_days: false).")
+ end
+
+ it "can still use 'ignore_non_working_days' as column name with `true` and `false` as values" do
+ expect(parsed_attributes(<<~TABLE))
+ | ignore_non_working_days |
+ | true |
+ | false |
+ TABLE
+ .to eq([{ ignore_non_working_days: true }, { ignore_non_working_days: false }])
+ end
+
+ it "raises an error if value is invalid" do
+ expect { parsed_attributes(<<~TABLE) }
+ | days counting |
+ | foo |
+ TABLE
+ .to raise_error("Invalid value for 'days counting' column: \"foo\". " \
+ "Expected 'all days' (ignore_non_working_days: true) " \
+ "or 'working days only' (ignore_non_working_days: false).")
+ end
+ end
+
+ describe "#format" do
+ it "maps `true` to 'all days'" do
+ expect(column_type.format(true)).to eq "all days"
+ end
+
+ it "maps `false` to 'working days only'" do
+ expect(column_type.format(false)).to eq "working days only"
+ end
+ end
+ end
+end
diff --git a/spec/support_spec/table_helpers/example_methods_spec.rb b/spec/support_spec/table_helpers/example_methods_spec.rb
new file mode 100644
index 00000000000..18f44454e40
--- /dev/null
+++ b/spec/support_spec/table_helpers/example_methods_spec.rb
@@ -0,0 +1,77 @@
+# frozen_string_literal: true
+
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) the OpenProject GmbH
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License version 3.
+#
+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
+# Copyright (C) 2006-2013 Jean-Philippe Lang
+# Copyright (C) 2010-2013 the ChiliProject Team
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# See COPYRIGHT and LICENSE files for more details.
+#++
+
+require "spec_helper"
+
+module TableHelpers
+ RSpec.describe ExampleMethods do
+ create_shared_association_defaults_for_work_package_factory
+
+ describe "change_work_packages" do
+ let(:fake_today) { Date.new(2022, 6, 16) } # Thursday 16 June 2022
+ let(:monday) { Date.new(2022, 6, 20) } # Monday 20 June
+ let(:tuesday) { Date.new(2022, 6, 21) }
+ let(:thursday) { Date.new(2022, 6, 23) }
+ let(:friday) { Date.new(2022, 6, 24) }
+
+ before do
+ travel_to(fake_today)
+ end
+
+ it "applies attribute changes to a group of work packages from a visual table representation" do
+ main = build_stubbed(:work_package, subject: "main")
+ second = build_stubbed(:work_package, subject: "second")
+ change_work_packages([main, second], <<~TABLE)
+ subject | MTWTFSS | scheduling mode |
+ main | XX | manual |
+ second | XX | automatic |
+ TABLE
+ expect(main.start_date).to eq(monday)
+ expect(main.due_date).to eq(tuesday)
+ expect(main.schedule_manually).to be(true)
+ expect(second.start_date).to eq(thursday)
+ expect(second.due_date).to eq(friday)
+ expect(second.schedule_manually).to be(false)
+ end
+
+ it "does not save changes" do
+ main = create(:work_package, subject: "main")
+ expect(main.persisted?).to be(true)
+ expect(main.has_changes_to_save?).to be(false)
+ change_work_packages([main], <<~TABLE)
+ subject | MTWTFSS |
+ main | XX |
+ TABLE
+ expect(main.has_changes_to_save?).to be(true)
+ expect(main.changes).to eq("start_date" => [nil, monday], "due_date" => [nil, tuesday])
+ end
+ end
+ end
+end
diff --git a/spec/workers/work_packages/apply_working_days_change_job_spec.rb b/spec/workers/work_packages/apply_working_days_change_job_spec.rb
index 8fa073cace0..5e84b0be6dd 100644
--- a/spec/workers/work_packages/apply_working_days_change_job_spec.rb
+++ b/spec/workers/work_packages/apply_working_days_change_job_spec.rb
@@ -67,14 +67,14 @@ RSpec.describe WorkPackages::ApplyWorkingDaysChangeJob do
context "with non-working weekday settings" do
context "when a work package includes a date that is now a non-working day" do
- let_schedule(<<~CHART)
- days | MTWTFSS |
+ let_work_packages(<<~TABLE)
+ subject | MTWTFSS |
work_package | XXXX ░░ |
work_package_on_start | XX ░░ |
work_package_on_due | XXX ░░ |
wp_start_only | [ ░░ |
wp_due_only | ] ░░ |
- CHART
+ TABLE
before do
set_non_working_week_days("wednesday")
@@ -83,14 +83,14 @@ RSpec.describe WorkPackages::ApplyWorkingDaysChangeJob do
it "moves the finish date to the corresponding number of now-excluded days to maintain duration [#31992]" do
subject
- expect(WorkPackage.all).to match_schedule(<<~CHART)
- days | MTWTFSS |
+ expect(WorkPackage.all).to match_table(<<~TABLE)
+ subject | MTWTFSS |
work_package | XX▓XX░░ |
work_package_on_start | ░XX░░ |
work_package_on_due | XX▓X ░░ |
wp_start_only | ░[ ░░ |
wp_due_only | ░] ░░ |
- CHART
+ TABLE
end
it_behaves_like "journal updates with cause" do
@@ -111,10 +111,10 @@ RSpec.describe WorkPackages::ApplyWorkingDaysChangeJob do
end
context "when a work package was scheduled to start on a date that is now a non-working day" do
- let_schedule(<<~CHART)
- days | MTWTFSS |
+ let_work_packages(<<~TABLE)
+ subject | MTWTFSS |
work_package | XX ░░ |
- CHART
+ TABLE
before do
set_non_working_week_days("wednesday")
@@ -123,10 +123,10 @@ RSpec.describe WorkPackages::ApplyWorkingDaysChangeJob do
it "moves the start date to the earliest working day in the future, " \
"and the finish date changes by consequence [#31992]" do
subject
- expect(WorkPackage.all).to match_schedule(<<~CHART)
- days | MTWTFSS |
+ expect(WorkPackage.all).to match_table(<<~TABLE)
+ subject | MTWTFSS |
work_package | ░XX░░ |
- CHART
+ TABLE
end
it_behaves_like "journal updates with cause" do
@@ -143,10 +143,10 @@ RSpec.describe WorkPackages::ApplyWorkingDaysChangeJob do
end
context "when a work package includes a date that is no more a non-working day" do
- let_schedule(<<~CHART)
- days | fssMTWTFSS |
+ let_work_packages(<<~TABLE)
+ subject | fssMTWTFSS |
work_package | X▓▓XX ░░ |
- CHART
+ TABLE
before do
set_working_week_days("saturday")
@@ -154,10 +154,10 @@ RSpec.describe WorkPackages::ApplyWorkingDaysChangeJob do
it "moves the finish date backwards to the corresponding number of now-included days to maintain duration [#31992]" do
subject
- expect(WorkPackage.all).to match_schedule(<<~CHART)
- days | fssMTWTFSS |
+ expect(WorkPackage.all).to match_table(<<~TABLE)
+ subject | fssMTWTFSS |
work_package | XX▓X ░ |
- CHART
+ TABLE
end
it_behaves_like "journal updates with cause" do
@@ -174,11 +174,11 @@ RSpec.describe WorkPackages::ApplyWorkingDaysChangeJob do
end
context "when a follower has a predecessor with dates covering a day that is now a non-working day" do
- let_schedule(<<~CHART)
- days | MTWTFSS |
- predecessor | XX ░░ | working days work week
- follower | XXX░ | working days include weekends, follows predecessor
- CHART
+ let_work_packages(<<~TABLE)
+ subject | MTWTFSS | days counting | scheduling mode | properties
+ predecessor | XX ░░ | working days only | manual |
+ follower | XXX░ | all days | automatic | follows predecessor
+ TABLE
before do
set_non_working_week_days("wednesday")
@@ -186,11 +186,11 @@ RSpec.describe WorkPackages::ApplyWorkingDaysChangeJob do
it "moves the follower start date by consequence of the predecessor dates shift [#31992]" do
subject
- expect(WorkPackage.all).to match_schedule(<<~CHART)
- days | MTWTFSS |
+ expect(WorkPackage.all).to match_table(<<~TABLE)
+ subject | MTWTFSS |
predecessor | X▓X ░░ |
follower | ░ XXX |
- CHART
+ TABLE
end
it_behaves_like "journal updates with cause" do
@@ -208,11 +208,11 @@ RSpec.describe WorkPackages::ApplyWorkingDaysChangeJob do
end
context "when a follower has a predecessor with lag covering a day that is now a non-working day" do
- let_schedule(<<~CHART)
- days | MTWTFSS |
- predecessor | XX ░░ |
- follower | X ░░ | follows predecessor with lag 1
- CHART
+ let_work_packages(<<~TABLE)
+ subject | MTWTFSS | scheduling mode | properties
+ predecessor | XX ░░ | manual |
+ follower | X ░░ | automatic | follows predecessor with lag 1
+ TABLE
before do
set_non_working_week_days("wednesday")
@@ -220,11 +220,11 @@ RSpec.describe WorkPackages::ApplyWorkingDaysChangeJob do
it "moves the follower start date forward to keep the lag to 1 day" do
subject
- expect(WorkPackage.all).to match_schedule(<<~CHART)
- days | MTWTFSS |
+ expect(WorkPackage.all).to match_table(<<~TABLE)
+ subject | MTWTFSS |
predecessor | XX░ ░░ |
follower | ░ X░░ |
- CHART
+ TABLE
end
it_behaves_like "journal updates with cause" do
@@ -244,11 +244,11 @@ RSpec.describe WorkPackages::ApplyWorkingDaysChangeJob do
end
context "with work packages without dates following each other with lag" do
- let_schedule(<<~CHART)
- days | MTWTFSS |
- predecessor | ░░ |
- follower | ░░ | follows predecessor with lag 5
- CHART
+ let_work_packages(<<~TABLE)
+ subject | MTWTFSS | scheduling mode | properties
+ predecessor | ░░ | manual |
+ follower | ░░ | automatic | follows predecessor with lag 5
+ TABLE
before do
set_non_working_week_days("wednesday")
@@ -256,11 +256,11 @@ RSpec.describe WorkPackages::ApplyWorkingDaysChangeJob do
it "does not move anything (obviously) and does not crash either" do
subject
- expect(WorkPackage.all).to match_schedule(<<~CHART)
- days | MTWTFSS |
+ expect(WorkPackage.all).to match_table(<<~TABLE)
+ subject | MTWTFSS |
predecessor | ░ ░░ |
follower | ░ ░░ |
- CHART
+ TABLE
end
it_behaves_like "journal updates with cause" do
@@ -271,11 +271,11 @@ RSpec.describe WorkPackages::ApplyWorkingDaysChangeJob do
end
context "when a follower has a predecessor with lag covering multiple days with different working changes" do
- let_schedule(<<~CHART)
- days | MTWTFSS |
- predecessor | X ░ ░░ |
- follower | ░ X░░ | follows predecessor with lag 2
- CHART
+ let_work_packages(<<~TABLE)
+ subject | MTWTFSS | scheduling mode | properties
+ predecessor | X ░ ░░ | manual |
+ follower | ░ X░░ | automatic | follows predecessor with lag 2
+ TABLE
let(:work_week) { set_work_week("monday", "tuesday", "thursday", "friday") }
before do
@@ -285,11 +285,11 @@ RSpec.describe WorkPackages::ApplyWorkingDaysChangeJob do
it "correctly handles the changes" do
subject
- expect_schedule(WorkPackage.all, <<~CHART)
- days | MTWTFSS |
+ expect_work_packages(WorkPackage.all, <<~TABLE)
+ subject | MTWTFSS |
predecessor | X░ ░░ |
follower | ░ X░░ |
- CHART
+ TABLE
end
it_behaves_like "journal updates with cause" do
@@ -300,11 +300,11 @@ RSpec.describe WorkPackages::ApplyWorkingDaysChangeJob do
end
context "when a follower has a predecessor with dates covering a day that is now a working day" do
- let_schedule(<<~CHART)
- days | MTWTFSS |
- predecessor | X▓X ░░ | working days work week
- follower | ░ XXX | working days include weekends, follows predecessor
- CHART
+ let_work_packages(<<~TABLE)
+ subject | MTWTFSS | days counting | scheduling mode | properties
+ predecessor | X▓X ░░ | working days only | manual |
+ follower | ░ XXX | all days | automatic | follows predecessor
+ TABLE
let(:work_week) { set_work_week("monday", "tuesday", "thursday", "friday") }
before do
@@ -314,11 +314,11 @@ RSpec.describe WorkPackages::ApplyWorkingDaysChangeJob do
it "does not move the follower backwards" do
subject
- expect_schedule(WorkPackage.all, <<~CHART)
- days | MTWTFSS |
+ expect_work_packages(WorkPackage.all, <<~TABLE)
+ subject | MTWTFSS |
predecessor | XX ░░ |
follower | XXX |
- CHART
+ TABLE
end
it_behaves_like "journal updates with cause" do
@@ -338,11 +338,11 @@ RSpec.describe WorkPackages::ApplyWorkingDaysChangeJob do
end
context "when a follower has a predecessor with a non-working day between them that is now a working day" do
- let_schedule(<<~CHART)
- days | MTWTFSS |
- predecessor | XX░ ░░ |
- follower | ░XX░░ | follows predecessor
- CHART
+ let_work_packages(<<~TABLE)
+ subject | MTWTFSS | scheduling mode | properties
+ predecessor | XX░ ░░ | manual |
+ follower | ░XX░░ | automatic | follows predecessor
+ TABLE
let(:work_week) { set_work_week("monday", "tuesday", "thursday", "friday") }
before do
@@ -351,11 +351,11 @@ RSpec.describe WorkPackages::ApplyWorkingDaysChangeJob do
it "does not move the follower" do
subject
- expect(WorkPackage.all).to match_schedule(<<~CHART)
- days | MTWTFSS |
+ expect(WorkPackage.all).to match_table(<<~TABLE)
+ subject | MTWTFSS |
predecessor | XX |
follower | XX░░ |
- CHART
+ TABLE
end
it_behaves_like "journal updates with cause" do
@@ -366,10 +366,10 @@ RSpec.describe WorkPackages::ApplyWorkingDaysChangeJob do
end
context "when a work package has working days include weekends, and includes a date that is now a non-working day" do
- let_schedule(<<~CHART)
- days | MTWTFSS |
- work_package | XXXX ░░ | working days include weekends
- CHART
+ let_work_packages(<<~TABLE)
+ subject | MTWTFSS | days counting |
+ work_package | XXXX ░░ | all days |
+ TABLE
before do
set_non_working_week_days("wednesday")
@@ -377,10 +377,10 @@ RSpec.describe WorkPackages::ApplyWorkingDaysChangeJob do
it "does not move any dates" do
subject
- expect(WorkPackage.all).to match_schedule(<<~CHART)
- days | MTWTFSS |
+ expect(WorkPackage.all).to match_table(<<~TABLE)
+ subject | MTWTFSS |
work_package | XXXX ░░ |
- CHART
+ TABLE
end
it_behaves_like "journal updates with cause" do
@@ -391,10 +391,10 @@ RSpec.describe WorkPackages::ApplyWorkingDaysChangeJob do
end
context "when a work package only has a duration" do
- let_schedule(<<~CHART)
- days | MTWTFSS |
- work_package | ░░ | duration 3 days
- CHART
+ let_work_packages(<<~TABLE)
+ subject | MTWTFSS | duration
+ work_package | ░░ | 3 days
+ TABLE
before do
set_non_working_week_days("wednesday")
@@ -413,28 +413,28 @@ RSpec.describe WorkPackages::ApplyWorkingDaysChangeJob do
end
context "when having multiple work packages following each other, and having days becoming non working days" do
- let_schedule(<<~CHART)
- days | MTWTFSS |
- wp1 | X▓▓XX | follows wp2
- wp2 | X ░░ | follows wp3
- wp3 | XXX ░░ |
- CHART
+ let_work_packages(<<~TABLE)
+ subject | MTWTFSS | scheduling mode | properties
+ wp1 | X▓▓XX | automatic | follows wp2
+ wp2 | X ░░ | automatic | follows wp3
+ wp3 | XXX ░░ | manual |
+ TABLE
before do
set_non_working_week_days("tuesday", "wednesday", "friday")
end
- it "updates them only once most of the time" do
+ it "updates them only once most of the time", :aggregate_failures do
expect { subject }
.to change { WorkPackage.pluck(:lock_version) }
.from([0, 0, 0])
.to([1, 1, 1])
- expect(WorkPackage.all).to match_schedule(<<~CHART)
- days | MTWTFSSmtwtfssmtwtfss |
- wp1 | ░░ ░░░ ░░ ░░░X▓▓X▓▓▓X |
- wp2 | ░░ ░░░ ░░X░░░ ░░ ░░░ |
- wp3 | X▓▓X▓▓▓X░░ ░░░ ░░ ░░░ |
- CHART
+ expect(WorkPackage.all).to match_table(<<~TABLE)
+ subject | MTWTFSSmtwtfssmtwtfss |
+ wp1 | ░░ ░░░ ░░ ░░░X▓▓X▓▓▓X |
+ wp2 | ░░ ░░░ ░░X░░░ ░░ ░░░ |
+ wp3 | X▓▓X▓▓▓X░░ ░░░ ░░ ░░░ |
+ TABLE
end
it_behaves_like "journal updates with cause" do
@@ -464,12 +464,12 @@ RSpec.describe WorkPackages::ApplyWorkingDaysChangeJob do
# * follower wp3 gets rescheduled and moves to next Monday
# * wp2 will move from Wednesday-Thursday to Thursday-nextMonday too and its followers will be rescheduled too
# * follower wp3 gets rescheduled *again* and moves to next Thursday
- let_schedule(<<~CHART)
- days | MTWTFSS |
- wp1 | X ░░ |
- wp2 | XX ░░ |
- wp3 | X░░ | follows wp1, follows wp2
- CHART
+ let_work_packages(<<~TABLE)
+ subject | MTWTFSS | scheduling mode | properties
+ wp1 | X ░░ | manual |
+ wp2 | XX ░░ | manual |
+ wp3 | X░░ | automatic | follows wp1, follows wp2
+ TABLE
before do
set_non_working_week_days("tuesday", "wednesday", "friday")
@@ -480,12 +480,12 @@ RSpec.describe WorkPackages::ApplyWorkingDaysChangeJob do
.to change { WorkPackage.order(:subject).pluck(:lock_version) }
.from([0, 0, 0])
.to([1, 1, 2])
- expect(WorkPackage.all).to match_schedule(<<~CHART)
- days | MTWTFSSmtwt |
- wp1 | ░░X░░░ ░░ |
- wp2 | ░░X▓▓▓X░░ |
- wp3 | ░░ ░░░ ░░X |
- CHART
+ expect(WorkPackage.all).to match_table(<<~TABLE)
+ subject | MTWTFSSmtwt |
+ wp1 | ░░X░░░ ░░ |
+ wp2 | ░░X▓▓▓X░░ |
+ wp3 | ░░ ░░░ ░░X |
+ TABLE
end
it_behaves_like "journal updates with cause" do
@@ -502,12 +502,12 @@ RSpec.describe WorkPackages::ApplyWorkingDaysChangeJob do
end
context "when having multiple work packages following each other, and having days becoming working days" do
- let_schedule(<<~CHART)
- days | MTWTFSSmtwtfssmtwtfss |
- wp1 | ░░ ░░░ ░░ ░░░X▓▓X▓▓▓X | follows wp2
- wp2 | ░░ ░░░ ░░X░░░ ░░ ░░░ | follows wp3
- wp3 | X▓▓X▓▓▓X░░ ░░░ ░░ ░░░ |
- CHART
+ let_work_packages(<<~TABLE)
+ subject | MTWTFSSmtwtfssmtwtfss | scheduling mode | properties
+ wp1 | ░░ ░░░ ░░ ░░░X▓▓X▓▓▓X | automatic | follows wp2
+ wp2 | ░░ ░░░ ░░X░░░ ░░ ░░░ | automatic | follows wp3
+ wp3 | X▓▓X▓▓▓X░░ ░░░ ░░ ░░░ | manual |
+ TABLE
let(:work_week) { set_work_week("monday", "thursday") }
@@ -517,12 +517,12 @@ RSpec.describe WorkPackages::ApplyWorkingDaysChangeJob do
it "keeps the same start dates and updates them only once" do
subject
- expect(WorkPackage.all).to match_schedule(<<~CHART)
- days | MTWTFSSmtwtfssmtwtfss |
- wp1 | ░░ ░░XXX ░░ | follows wp2
- wp2 | ░░ X ░░ ░░ | follows wp3
- wp3 | XXX ░░ ░░ ░░ |
- CHART
+ expect(WorkPackage.all).to match_table(<<~TABLE)
+ subject | MTWTFSSmtwtfssmtwtfss | properties
+ wp1 | ░░ ░░XXX ░░ | follows wp2
+ wp2 | ░░ X ░░ ░░ | follows wp3
+ wp3 | XXX ░░ ░░ ░░ |
+ TABLE
expect(WorkPackage.pluck(:lock_version)).to all(be <= 1)
end
@@ -543,12 +543,12 @@ RSpec.describe WorkPackages::ApplyWorkingDaysChangeJob do
end
context "when having multiple work packages following each other and first one only has a due date" do
- let_schedule(<<~CHART)
- days | MTWTFSS |
- wp1 | X▓▓XX | follows wp2
- wp2 | XX ░░ | follows wp3
- wp3 | ] ░░ |
- CHART
+ let_work_packages(<<~TABLE)
+ subject | MTWTFSS | scheduling mode | properties
+ wp1 | X▓▓XX | automatic | follows wp2
+ wp2 | XX ░░ | automatic | follows wp3
+ wp3 | ] ░░ | manual |
+ TABLE
before do
set_non_working_week_days("tuesday", "wednesday", "friday")
@@ -559,12 +559,12 @@ RSpec.describe WorkPackages::ApplyWorkingDaysChangeJob do
.to change { WorkPackage.pluck(:lock_version) }
.from([0, 0, 0])
.to([1, 1, 1])
- expect(WorkPackage.all).to match_schedule(<<~CHART)
- days | MTWTFSSm t ssm t ssm |
- wp1 | ░░ ░░░ ░░ ░░░X▓▓X▓▓▓X |
- wp2 | ░░ ░░░X▓▓X░░░ ░░ ░░░ |
- wp3 | ░░]░░░ ░░ ░░░ ░░ ░░░ |
- CHART
+ expect(WorkPackage.all).to match_table(<<~TABLE)
+ subject | MTWTFSSm t ssm t ssm |
+ wp1 | ░░ ░░░ ░░ ░░░X▓▓X▓▓▓X |
+ wp2 | ░░ ░░░X▓▓X░░░ ░░ ░░░ |
+ wp3 | ░░]░░░ ░░ ░░░ ░░ ░░░ |
+ TABLE
end
it_behaves_like "journal updates with cause" do
@@ -581,10 +581,10 @@ RSpec.describe WorkPackages::ApplyWorkingDaysChangeJob do
end
context "when turning Sunday into a working day" do
- let_schedule(<<~CHART)
- days | MTWTFSSm |
+ let_work_packages(<<~TABLE)
+ subject | MTWTFSSm |
work_package | X▓▓X |
- CHART
+ TABLE
before do
set_working_week_days("Sunday")
@@ -610,14 +610,14 @@ RSpec.describe WorkPackages::ApplyWorkingDaysChangeJob do
let!(:previous_non_working_days) { week_with_saturday_and_sunday_as_non_working_day }
context "when a work package includes a date that is now a non-working day" do
- let_schedule(<<~CHART)
- days | MTWTFSS |
+ let_work_packages(<<~TABLE)
+ subject | MTWTFSS |
work_package | XXXX ░░ |
work_package_on_start | XX ░░ |
work_package_on_due | XXX ░░ |
wp_start_only | [ ░░ |
wp_due_only | ] ░░ |
- CHART
+ TABLE
before do
set_non_working_days(next_monday.next_occurring(:wednesday))
@@ -626,14 +626,14 @@ RSpec.describe WorkPackages::ApplyWorkingDaysChangeJob do
it "moves the finish date to the corresponding number of now-excluded days to maintain duration [#31992]" do
subject
- expect(WorkPackage.all).to match_schedule(<<~CHART)
- days | MTWTFSS |
+ expect(WorkPackage.all).to match_table(<<~TABLE)
+ subject | MTWTFSS |
work_package | XX▓XX░░ |
work_package_on_start | ░XX░░ |
work_package_on_due | XX▓X ░░ |
wp_start_only | ░[ ░░ |
wp_due_only | ░] ░░ |
- CHART
+ TABLE
end
it_behaves_like "journal updates with cause" do
@@ -655,10 +655,10 @@ RSpec.describe WorkPackages::ApplyWorkingDaysChangeJob do
end
context "when a work package was scheduled to start on a date that is now a non-working day" do
- let_schedule(<<~CHART)
- days | MTWTFSS |
+ let_work_packages(<<~TABLE)
+ subject | MTWTFSS |
work_package | XX ░░ |
- CHART
+ TABLE
before do
set_non_working_days(next_monday.next_occurring(:wednesday))
@@ -667,10 +667,10 @@ RSpec.describe WorkPackages::ApplyWorkingDaysChangeJob do
it "moves the start date to the earliest working day in the future, " \
"and the finish date changes by consequence [#31992]" do
subject
- expect(WorkPackage.all).to match_schedule(<<~CHART)
- days | MTWTFSS |
+ expect(WorkPackage.all).to match_table(<<~TABLE)
+ subject | MTWTFSS |
work_package | ░XX░░ |
- CHART
+ TABLE
end
it_behaves_like "journal updates with cause" do
@@ -688,10 +688,10 @@ RSpec.describe WorkPackages::ApplyWorkingDaysChangeJob do
end
context "when a work package includes a date that is no more a non-working day" do
- let_schedule(<<~CHART)
- days | fssMTWTFSS |
+ let_work_packages(<<~TABLE)
+ subject | fssMTWTFSS |
work_package | X▓▓XX ░░ |
- CHART
+ TABLE
before do
set_working_days(monday.next_occurring(:saturday))
@@ -699,10 +699,10 @@ RSpec.describe WorkPackages::ApplyWorkingDaysChangeJob do
it "moves the finish date backwards to the corresponding number of now-included days to maintain duration [#31992]" do
subject
- expect(WorkPackage.all).to match_schedule(<<~CHART)
- days | fssMTWTFSS |
+ expect(WorkPackage.all).to match_table(<<~TABLE)
+ subject | fssMTWTFSS |
work_package | XX▓X ░ |
- CHART
+ TABLE
end
it_behaves_like "journal updates with cause" do
@@ -720,11 +720,11 @@ RSpec.describe WorkPackages::ApplyWorkingDaysChangeJob do
end
context "when a follower has a predecessor with dates covering a day that is now a non-working day" do
- let_schedule(<<~CHART)
- days | MTWTFSS |
- predecessor | XX ░░ | working days work week
- follower | XXX░ | working days include weekends, follows predecessor
- CHART
+ let_work_packages(<<~TABLE)
+ subject | MTWTFSS | days counting | scheduling mode | properties
+ predecessor | XX ░░ | working days only | manual |
+ follower | XXX░ | all days | automatic | follows predecessor
+ TABLE
before do
set_non_working_days(next_monday.next_occurring(:wednesday))
@@ -732,11 +732,11 @@ RSpec.describe WorkPackages::ApplyWorkingDaysChangeJob do
it "moves the follower start date by consequence of the predecessor dates shift [#31992]" do
subject
- expect(WorkPackage.all).to match_schedule(<<~CHART)
- days | MTWTFSS |
+ expect(WorkPackage.all).to match_table(<<~TABLE)
+ subject | MTWTFSS |
predecessor | X▓X ░░ |
follower | ░ XXX |
- CHART
+ TABLE
end
it_behaves_like "journal updates with cause" do
@@ -754,11 +754,11 @@ RSpec.describe WorkPackages::ApplyWorkingDaysChangeJob do
end
context "when a follower has a predecessor with lag covering a day that is now a non-working day" do
- let_schedule(<<~CHART)
- days | MTWTFSS |
- predecessor | XX ░░ |
- follower | X ░░ | follows predecessor with lag 1
- CHART
+ let_work_packages(<<~TABLE)
+ subject | MTWTFSS | scheduling mode | properties
+ predecessor | XX ░░ | manual |
+ follower | X ░░ | automatic | follows predecessor with lag 1
+ TABLE
before do
set_non_working_days(next_monday.next_occurring(:wednesday))
@@ -766,11 +766,11 @@ RSpec.describe WorkPackages::ApplyWorkingDaysChangeJob do
it "moves the follower start date forward to keep the lag to 1 day" do
subject
- expect(WorkPackage.all).to match_schedule(<<~CHART)
- days | MTWTFSS |
+ expect(WorkPackage.all).to match_table(<<~TABLE)
+ subject | MTWTFSS |
predecessor | XX░ ░░ |
follower | ░ X░░ |
- CHART
+ TABLE
end
it_behaves_like "journal updates with cause" do
@@ -790,11 +790,11 @@ RSpec.describe WorkPackages::ApplyWorkingDaysChangeJob do
end
context "with work packages without dates following each other with lag" do
- let_schedule(<<~CHART)
- days | MTWTFSS |
- predecessor | ░░ |
- follower | ░░ | follows predecessor with lag 5
- CHART
+ let_work_packages(<<~TABLE)
+ subject | MTWTFSS | scheduling mode | properties
+ predecessor | ░░ | manual |
+ follower | ░░ | automatic | follows predecessor with lag 5
+ TABLE
before do
set_non_working_days(next_monday.next_occurring(:wednesday))
@@ -802,11 +802,11 @@ RSpec.describe WorkPackages::ApplyWorkingDaysChangeJob do
it "does not move anything (obviously) and does not crash either" do
subject
- expect(WorkPackage.all).to match_schedule(<<~CHART)
- days | MTWTFSS |
+ expect(WorkPackage.all).to match_table(<<~TABLE)
+ subject | MTWTFSS |
predecessor | ░ ░░ |
follower | ░ ░░ |
- CHART
+ TABLE
end
it_behaves_like "journal updates with cause" do
@@ -817,11 +817,11 @@ RSpec.describe WorkPackages::ApplyWorkingDaysChangeJob do
end
context "when a follower has a predecessor with lag covering multiple days with different working changes" do
- let_schedule(<<~CHART)
- days | MTWTFSS |
- predecessor | X ░ ░░ |
- follower | ░ X░░ | follows predecessor with lag 2
- CHART
+ let_work_packages(<<~TABLE)
+ subject | MTWTFSS | scheduling mode | properties
+ predecessor | X ░ ░░ | manual |
+ follower | ░ X░░ | automatic | follows predecessor with lag 2
+ TABLE
let(:non_working_day) { create(:non_working_day, date: next_monday.next_occurring(:wednesday)) }
@@ -836,11 +836,11 @@ RSpec.describe WorkPackages::ApplyWorkingDaysChangeJob do
it "correctly handles the changes" do
subject
- expect_schedule(WorkPackage.all, <<~CHART)
- days | MTWTFSS |
+ expect_work_packages(WorkPackage.all, <<~TABLE)
+ subject | MTWTFSS |
predecessor | X░ ░░ |
follower | ░ X░░ |
- CHART
+ TABLE
end
it_behaves_like "journal updates with cause" do
@@ -851,11 +851,11 @@ RSpec.describe WorkPackages::ApplyWorkingDaysChangeJob do
end
context "when a follower has a predecessor with dates covering a day that is now a working day" do
- let_schedule(<<~CHART)
- days | MTWTFSS |
- predecessor | X▓X ░░ | working days work week
- follower | ░ XXX | working days include weekends, follows predecessor
- CHART
+ let_work_packages(<<~TABLE)
+ subject | MTWTFSS | days counting | scheduling mode | properties
+ predecessor | X▓X ░░ | working days only | manual |
+ follower | ░ XXX | all days | automatic | follows predecessor
+ TABLE
let(:non_working_day) { create(:non_working_day, date: next_monday.next_occurring(:wednesday)) }
let!(:previous_non_working_days) do
@@ -869,11 +869,11 @@ RSpec.describe WorkPackages::ApplyWorkingDaysChangeJob do
it "does not move the follower backwards" do
subject
- expect_schedule(WorkPackage.all, <<~CHART)
- days | MTWTFSS |
+ expect_work_packages(WorkPackage.all, <<~TABLE)
+ subject | MTWTFSS |
predecessor | XX ░░ |
follower | XXX |
- CHART
+ TABLE
end
it_behaves_like "journal updates with cause" do
@@ -893,11 +893,11 @@ RSpec.describe WorkPackages::ApplyWorkingDaysChangeJob do
end
context "when a follower has a predecessor with a non-working day between them that is now a working day" do
- let_schedule(<<~CHART)
- days | MTWTFSS |
- predecessor | XX░ ░░ |
- follower | ░XX░░ | follows predecessor
- CHART
+ let_work_packages(<<~TABLE)
+ subject | MTWTFSS | scheduling mode | properties
+ predecessor | XX░ ░░ | manual |
+ follower | ░XX░░ | automatic | follows predecessor
+ TABLE
let(:non_working_day) { create(:non_working_day, date: next_monday.next_occurring(:wednesday)) }
let!(:previous_non_working_days) do
@@ -910,11 +910,11 @@ RSpec.describe WorkPackages::ApplyWorkingDaysChangeJob do
it "does not move the follower" do
subject
- expect(WorkPackage.all).to match_schedule(<<~CHART)
- days | MTWTFSS |
+ expect(WorkPackage.all).to match_table(<<~TABLE)
+ subject | MTWTFSS |
predecessor | XX |
follower | XX░░ |
- CHART
+ TABLE
end
it_behaves_like "journal updates with cause" do
@@ -925,10 +925,10 @@ RSpec.describe WorkPackages::ApplyWorkingDaysChangeJob do
end
context "when a work package has working days include weekends, and includes a date that is now a non-working day" do
- let_schedule(<<~CHART)
- days | MTWTFSS |
- work_package | XXXX ░░ | working days include weekends
- CHART
+ let_work_packages(<<~TABLE)
+ subject | MTWTFSS | days counting |
+ work_package | XXXX ░░ | all days |
+ TABLE
before do
set_non_working_days(next_monday.next_occurring(:wednesday))
@@ -936,10 +936,10 @@ RSpec.describe WorkPackages::ApplyWorkingDaysChangeJob do
it "does not move any dates" do
subject
- expect(WorkPackage.all).to match_schedule(<<~CHART)
- days | MTWTFSS |
+ expect(WorkPackage.all).to match_table(<<~TABLE)
+ subject | MTWTFSS |
work_package | XXXX ░░ |
- CHART
+ TABLE
end
it_behaves_like "journal updates with cause" do
@@ -950,10 +950,10 @@ RSpec.describe WorkPackages::ApplyWorkingDaysChangeJob do
end
context "when a work package only has a duration" do
- let_schedule(<<~CHART)
- days | MTWTFSS |
- work_package | ░░ | duration 3 days
- CHART
+ let_work_packages(<<~TABLE)
+ subject | MTWTFSS | duration
+ work_package | ░░ | 3 days
+ TABLE
before do
set_non_working_days(next_monday.next_occurring(:wednesday))
@@ -972,12 +972,12 @@ RSpec.describe WorkPackages::ApplyWorkingDaysChangeJob do
end
context "when having multiple work packages following each other, and having days becoming non working days" do
- let_schedule(<<~CHART)
- days | MTWTFSS |
- wp1 | X▓▓XX | follows wp2
- wp2 | X ░░ | follows wp3
- wp3 | XXX ░░ |
- CHART
+ let_work_packages(<<~TABLE)
+ subject | MTWTFSS | scheduling mode | properties
+ wp1 | X▓▓XX | automatic | follows wp2
+ wp2 | X ░░ | automatic | follows wp3
+ wp3 | XXX ░░ | manual |
+ TABLE
let(:non_working_days) do
[
@@ -998,12 +998,12 @@ RSpec.describe WorkPackages::ApplyWorkingDaysChangeJob do
.to change { WorkPackage.pluck(:lock_version) }
.from([0, 0, 0])
.to([1, 1, 1])
- expect(WorkPackage.all).to match_schedule(<<~CHART)
- days | MTWTFSSmtwtfssmtwtfss |
- wp1 | ░░ ░░░ ░░ ░░░X▓▓X▓▓▓X |
- wp2 | ░░ ░░░ ░░X░░░ ░░ ░░░ |
- wp3 | X▓▓X▓▓▓X░░ ░░░ ░░ ░░░ |
- CHART
+ expect(WorkPackage.all).to match_table(<<~TABLE)
+ subject | MTWTFSSmtwtfssmtwtfss |
+ wp1 | ░░ ░░░ ░░ ░░░X▓▓X▓▓▓X |
+ wp2 | ░░ ░░░ ░░X░░░ ░░ ░░░ |
+ wp3 | X▓▓X▓▓▓X░░ ░░░ ░░ ░░░ |
+ TABLE
end
it_behaves_like "journal updates with cause" do
@@ -1029,12 +1029,12 @@ RSpec.describe WorkPackages::ApplyWorkingDaysChangeJob do
# * follower wp3 gets rescheduled and moves to next Monday
# * wp2 will move from Wednesday-Thursday to Thursday-nextMonday too and its followers will be rescheduled too
# * follower wp3 gets rescheduled *again* and moves to next Thursday
- let_schedule(<<~CHART)
- days | MTWTFSS |
- wp1 | X ░░ |
- wp2 | XX ░░ |
- wp3 | X░░ | follows wp1, follows wp2
- CHART
+ let_work_packages(<<~TABLE)
+ subject | MTWTFSS | scheduling mode | properties
+ wp1 | X ░░ | manual |
+ wp2 | XX ░░ | manual |
+ wp3 | X░░ | automatic | follows wp1, follows wp2
+ TABLE
let(:non_working_days) do
[
@@ -1053,12 +1053,12 @@ RSpec.describe WorkPackages::ApplyWorkingDaysChangeJob do
.to change { WorkPackage.order(:subject).pluck(:lock_version) }
.from([0, 0, 0])
.to([1, 1, 2])
- expect(WorkPackage.all).to match_schedule(<<~CHART)
- days | MTWTFSSmtwt |
- wp1 | ░░X░░░ ░░ |
- wp2 | ░░X▓▓▓X░░ |
- wp3 | ░░ ░░░ ░░X |
- CHART
+ expect(WorkPackage.all).to match_table(<<~TABLE)
+ subject | MTWTFSSmtwt |
+ wp1 | ░░X░░░ ░░ |
+ wp2 | ░░X▓▓▓X░░ |
+ wp3 | ░░ ░░░ ░░X |
+ TABLE
end
it_behaves_like "journal updates with cause" do
@@ -1075,12 +1075,12 @@ RSpec.describe WorkPackages::ApplyWorkingDaysChangeJob do
end
context "when having multiple work packages following each other, and having days becoming working days" do
- let_schedule(<<~CHART)
- days | MTWTFSSmtwtfssmtwtfss |
- wp1 | ░░ ░░░ ░░ ░░░X▓▓X▓▓▓X | follows wp2
- wp2 | ░░ ░░░ ░░X░░░ ░░ ░░░ | follows wp3
- wp3 | X▓▓X▓▓▓X░░ ░░░ ░░ ░░░ |
- CHART
+ let_work_packages(<<~TABLE)
+ subject | MTWTFSSmtwtfssmtwtfss | scheduling mode | properties
+ wp1 | ░░ ░░░ ░░ ░░░X▓▓X▓▓▓X | automatic | follows wp2
+ wp2 | ░░ ░░░ ░░X░░░ ░░ ░░░ | automatic | follows wp3
+ wp3 | X▓▓X▓▓▓X░░ ░░░ ░░ ░░░ | manual |
+ TABLE
let(:non_working_days) do
[
@@ -1102,12 +1102,12 @@ RSpec.describe WorkPackages::ApplyWorkingDaysChangeJob do
it "keeps the same start dates and updates them only once" do
subject
- expect(WorkPackage.all).to match_schedule(<<~CHART)
- days | MTWTFSSmtwtfssmtwtfss |
- wp1 | ░░ ░░XXX ░░ | follows wp2
- wp2 | ░░ X ░░ ░░ | follows wp3
- wp3 | XXX ░░ ░░ ░░ |
- CHART
+ expect(WorkPackage.all).to match_table(<<~TABLE)
+ subject | MTWTFSSmtwtfssmtwtfss | properties
+ wp1 | ░░ ░░XXX ░░ | follows wp2
+ wp2 | ░░ X ░░ ░░ | follows wp3
+ wp3 | XXX ░░ ░░ ░░ |
+ TABLE
expect(WorkPackage.pluck(:lock_version)).to all(be <= 1)
end
@@ -1128,12 +1128,12 @@ RSpec.describe WorkPackages::ApplyWorkingDaysChangeJob do
end
context "when having multiple work packages following each other and first one only has a due date" do
- let_schedule(<<~CHART)
- days | MTWTFSS |
- wp1 | X▓▓XX | follows wp2
- wp2 | XX ░░ | follows wp3
- wp3 | ] ░░ |
- CHART
+ let_work_packages(<<~TABLE)
+ subject | MTWTFSS | scheduling mode | properties
+ wp1 | X▓▓XX | automatic | follows wp2
+ wp2 | XX ░░ | automatic | follows wp3
+ wp3 | ] ░░ | manual |
+ TABLE
let(:non_working_days) do
[
@@ -1154,12 +1154,12 @@ RSpec.describe WorkPackages::ApplyWorkingDaysChangeJob do
.to change { WorkPackage.pluck(:lock_version) }
.from([0, 0, 0])
.to([1, 1, 1])
- expect(WorkPackage.all).to match_schedule(<<~CHART)
- days | MTWTFSSm t ssm t ssm |
- wp1 | ░░ ░░░ ░░ ░░░X▓▓X▓▓▓X |
- wp2 | ░░ ░░░X▓▓X░░░ ░░ ░░░ |
- wp3 | ░░]░░░ ░░ ░░░ ░░ ░░░ |
- CHART
+ expect(WorkPackage.all).to match_table(<<~TABLE)
+ subject | MTWTFSSm t ssm t ssm |
+ wp1 | ░░ ░░░ ░░ ░░░X▓▓X▓▓▓X |
+ wp2 | ░░ ░░░X▓▓X░░░ ░░ ░░░ |
+ wp3 | ░░]░░░ ░░ ░░░ ░░ ░░░ |
+ TABLE
end
it_behaves_like "journal updates with cause" do
@@ -1177,10 +1177,10 @@ RSpec.describe WorkPackages::ApplyWorkingDaysChangeJob do
end
context "when turning Sunday into a working day" do
- let_schedule(<<~CHART)
- days | MTWTFSSm |
+ let_work_packages(<<~TABLE)
+ subject | MTWTFSSm |
work_package | X▓▓X |
- CHART
+ TABLE
let(:non_working_days) do
[monday.next_occurring(:sunday), next_monday.next_occurring(:sunday)]
@@ -1211,14 +1211,14 @@ RSpec.describe WorkPackages::ApplyWorkingDaysChangeJob do
# Leaving them as is, we get a mix of non-working days and weekday settings.
context "when a work package includes a date that is now a non-working day" do
- let_schedule(<<~CHART)
- days | MTWTFSS |
+ let_work_packages(<<~TABLE)
+ subject | MTWTFSS |
work_package | XXXX ░░ |
work_package_on_start | XX ░░ |
work_package_on_due | XXX ░░ |
wp_start_only | [ ░░ |
wp_due_only | ] ░░ |
- CHART
+ TABLE
before do
set_non_working_days(next_monday.next_occurring(:wednesday))
@@ -1227,14 +1227,14 @@ RSpec.describe WorkPackages::ApplyWorkingDaysChangeJob do
it "moves the finish date to the corresponding number of now-excluded days to maintain duration [#31992]" do
subject
- expect(WorkPackage.all).to match_schedule(<<~CHART)
- days | MTWTFSS |
+ expect(WorkPackage.all).to match_table(<<~TABLE)
+ subject | MTWTFSS |
work_package | XX▓XX░░ |
work_package_on_start | ░XX░░ |
work_package_on_due | XX▓X ░░ |
wp_start_only | ░[ ░░ |
wp_due_only | ░] ░░ |
- CHART
+ TABLE
end
it_behaves_like "journal updates with cause" do
@@ -1255,10 +1255,10 @@ RSpec.describe WorkPackages::ApplyWorkingDaysChangeJob do
end
context "when a work package was scheduled to start on a date that is now a non-working day" do
- let_schedule(<<~CHART)
- days | MTWTFSS |
+ let_work_packages(<<~TABLE)
+ subject | MTWTFSS |
work_package | XX ░░ |
- CHART
+ TABLE
before do
set_non_working_days(next_monday.next_occurring(:wednesday))
@@ -1267,10 +1267,10 @@ RSpec.describe WorkPackages::ApplyWorkingDaysChangeJob do
it "moves the start date to the earliest working day in the future, " \
"and the finish date changes by consequence [#31992]" do
subject
- expect(WorkPackage.all).to match_schedule(<<~CHART)
- days | MTWTFSS |
+ expect(WorkPackage.all).to match_table(<<~TABLE)
+ subject | MTWTFSS |
work_package | ░XX░░ |
- CHART
+ TABLE
end
it_behaves_like "journal updates with cause" do
@@ -1287,10 +1287,10 @@ RSpec.describe WorkPackages::ApplyWorkingDaysChangeJob do
end
context "when a work package includes a date that is no more a non-working day" do
- let_schedule(<<~CHART)
- days | fssMTWTFSS |
+ let_work_packages(<<~TABLE)
+ subject | fssMTWTFSS |
work_package | X▓▓XX ░░ |
- CHART
+ TABLE
let!(:previous_non_working_days) { week_with_saturday_and_sunday_as_non_working_day }
@@ -1301,10 +1301,10 @@ RSpec.describe WorkPackages::ApplyWorkingDaysChangeJob do
it "moves the finish date backwards to the corresponding number of now-included days to maintain duration [#31992]" do
subject
- expect(WorkPackage.all).to match_schedule(<<~CHART)
- days | fssMTWTFSS |
+ expect(WorkPackage.all).to match_table(<<~TABLE)
+ subject | fssMTWTFSS |
work_package | XX▓X ░ |
- CHART
+ TABLE
end
it_behaves_like "journal updates with cause" do
@@ -1322,11 +1322,11 @@ RSpec.describe WorkPackages::ApplyWorkingDaysChangeJob do
end
context "when a follower has a predecessor with dates covering a day that is now a non-working day" do
- let_schedule(<<~CHART)
- days | MTWTFSS |
- predecessor | XX ░░ | working days work week
- follower | XXX░ | working days include weekends, follows predecessor
- CHART
+ let_work_packages(<<~TABLE)
+ subject | MTWTFSS | days counting | scheduling mode | properties
+ predecessor | XX ░░ | working days only | manual |
+ follower | XXX░ | all days | automatic | follows predecessor
+ TABLE
before do
set_non_working_days(next_monday.next_occurring(:wednesday))
@@ -1334,11 +1334,11 @@ RSpec.describe WorkPackages::ApplyWorkingDaysChangeJob do
it "moves the follower start date by consequence of the predecessor dates shift [#31992]" do
subject
- expect(WorkPackage.all).to match_schedule(<<~CHART)
- days | MTWTFSS |
+ expect(WorkPackage.all).to match_table(<<~TABLE)
+ subject | MTWTFSS |
predecessor | X▓X ░░ |
follower | ░ XXX |
- CHART
+ TABLE
end
it_behaves_like "journal updates with cause" do
@@ -1356,11 +1356,11 @@ RSpec.describe WorkPackages::ApplyWorkingDaysChangeJob do
end
context "when a follower has a predecessor with lag covering a day that is now a non-working day" do
- let_schedule(<<~CHART)
- days | MTWTFSS |
- predecessor | XX ░░ |
- follower | X ░░ | follows predecessor with lag 1
- CHART
+ let_work_packages(<<~TABLE)
+ subject | MTWTFSS | scheduling mode | properties
+ predecessor | XX ░░ | manual |
+ follower | X ░░ | automatic | follows predecessor with lag 1
+ TABLE
before do
set_non_working_days(next_monday.next_occurring(:wednesday))
@@ -1368,11 +1368,11 @@ RSpec.describe WorkPackages::ApplyWorkingDaysChangeJob do
it "moves the follower start date forward to keep the lag to 1 day" do
subject
- expect(WorkPackage.all).to match_schedule(<<~CHART)
- days | MTWTFSS |
+ expect(WorkPackage.all).to match_table(<<~TABLE)
+ subject | MTWTFSS |
predecessor | XX░ ░░ |
follower | ░ X░░ |
- CHART
+ TABLE
end
it_behaves_like "journal updates with cause" do
@@ -1392,11 +1392,11 @@ RSpec.describe WorkPackages::ApplyWorkingDaysChangeJob do
end
context "with work packages without dates following each other with lag" do
- let_schedule(<<~CHART)
- days | MTWTFSS |
- predecessor | ░░ |
- follower | ░░ | follows predecessor with lag 5
- CHART
+ let_work_packages(<<~TABLE)
+ subject | MTWTFSS | scheduling mode | properties
+ predecessor | ░░ | manual |
+ follower | ░░ | automatic | follows predecessor with lag 5
+ TABLE
before do
set_non_working_days(next_monday.next_occurring(:wednesday))
@@ -1404,11 +1404,11 @@ RSpec.describe WorkPackages::ApplyWorkingDaysChangeJob do
it "does not move anything (obviously) and does not crash either" do
subject
- expect(WorkPackage.all).to match_schedule(<<~CHART)
- days | MTWTFSS |
+ expect(WorkPackage.all).to match_table(<<~TABLE)
+ subject | MTWTFSS |
predecessor | ░ ░░ |
follower | ░ ░░ |
- CHART
+ TABLE
end
it_behaves_like "journal updates with cause" do
@@ -1418,12 +1418,12 @@ RSpec.describe WorkPackages::ApplyWorkingDaysChangeJob do
end
end
- context "when a follower has a predecessor with delay covering multiple days with different working changes" do
- let_schedule(<<~CHART)
- days | MTWTFSS |
- predecessor | X ░ ░░ |
- follower | ░ X░░ | follows predecessor with delay 2
- CHART
+ context "when a follower has a predecessor with lag covering multiple days with different working changes" do
+ let_work_packages(<<~TABLE)
+ subject | MTWTFSS | scheduling mode | properties
+ predecessor | X ░ ░░ | manual |
+ follower | ░ X░░ | automatic | follows predecessor with lag 2
+ TABLE
let(:non_working_day) { create(:non_working_day, date: next_monday.next_occurring(:wednesday)) }
@@ -1438,11 +1438,11 @@ RSpec.describe WorkPackages::ApplyWorkingDaysChangeJob do
it "correctly handles the changes" do
subject
- expect_schedule(WorkPackage.all, <<~CHART)
- days | MTWTFSS |
+ expect_work_packages(WorkPackage.all, <<~TABLE)
+ subject | MTWTFSS |
predecessor | X░ ░░ |
follower | ░ X░░ |
- CHART
+ TABLE
end
it_behaves_like "journal updates with cause" do
@@ -1453,11 +1453,11 @@ RSpec.describe WorkPackages::ApplyWorkingDaysChangeJob do
end
context "when a follower has a predecessor with dates covering a day that is now a working day" do
- let_schedule(<<~CHART)
- days | MTWTFSS |
- predecessor | X▓X ░░ | working days work week
- follower | ░ XXX | working days include weekends, follows predecessor
- CHART
+ let_work_packages(<<~TABLE)
+ subject | MTWTFSS | days counting | scheduling mode | properties
+ predecessor | X▓X ░░ | working days only | manual |
+ follower | ░ XXX | all days | automatic | follows predecessor
+ TABLE
let(:non_working_day) { create(:non_working_day, date: next_monday.next_occurring(:wednesday)) }
let!(:previous_non_working_days) do
@@ -1471,11 +1471,11 @@ RSpec.describe WorkPackages::ApplyWorkingDaysChangeJob do
it "does not move the follower backwards" do
subject
- expect_schedule(WorkPackage.all, <<~CHART)
- days | MTWTFSS |
+ expect_work_packages(WorkPackage.all, <<~TABLE)
+ subject | MTWTFSS |
predecessor | XX ░░ |
follower | XXX |
- CHART
+ TABLE
end
it_behaves_like "journal updates with cause" do
@@ -1495,11 +1495,11 @@ RSpec.describe WorkPackages::ApplyWorkingDaysChangeJob do
end
context "when a follower has a predecessor with a non-working day between them that is now a working day" do
- let_schedule(<<~CHART)
- days | MTWTFSS |
- predecessor | XX░ ░░ |
- follower | ░XX░░ | follows predecessor
- CHART
+ let_work_packages(<<~TABLE)
+ subject | MTWTFSS | scheduling mode | properties
+ predecessor | XX░ ░░ | manual |
+ follower | ░XX░░ | automatic | follows predecessor
+ TABLE
let(:non_working_day) { create(:non_working_day, date: next_monday.next_occurring(:wednesday)) }
let!(:previous_non_working_days) do
@@ -1512,11 +1512,11 @@ RSpec.describe WorkPackages::ApplyWorkingDaysChangeJob do
it "does not move the follower" do
subject
- expect(WorkPackage.all).to match_schedule(<<~CHART)
- days | MTWTFSS |
+ expect(WorkPackage.all).to match_table(<<~TABLE)
+ subject | MTWTFSS |
predecessor | XX |
follower | XX░░ |
- CHART
+ TABLE
end
it_behaves_like "journal updates with cause" do
@@ -1527,10 +1527,10 @@ RSpec.describe WorkPackages::ApplyWorkingDaysChangeJob do
end
context "when a work package has working days include weekends, and includes a date that is now a non-working day" do
- let_schedule(<<~CHART)
- days | MTWTFSS |
- work_package | XXXX ░░ | working days include weekends
- CHART
+ let_work_packages(<<~TABLE)
+ subject | MTWTFSS | days counting |
+ work_package | XXXX ░░ | all days |
+ TABLE
before do
set_non_working_days(next_monday.next_occurring(:wednesday))
@@ -1538,10 +1538,10 @@ RSpec.describe WorkPackages::ApplyWorkingDaysChangeJob do
it "does not move any dates" do
subject
- expect(WorkPackage.all).to match_schedule(<<~CHART)
- days | MTWTFSS |
+ expect(WorkPackage.all).to match_table(<<~TABLE)
+ subject | MTWTFSS |
work_package | XXXX ░░ |
- CHART
+ TABLE
end
it_behaves_like "journal updates with cause" do
@@ -1552,10 +1552,10 @@ RSpec.describe WorkPackages::ApplyWorkingDaysChangeJob do
end
context "when a work package only has a duration" do
- let_schedule(<<~CHART)
- days | MTWTFSS |
- work_package | ░░ | duration 3 days
- CHART
+ let_work_packages(<<~TABLE)
+ subject | MTWTFSS | duration
+ work_package | ░░ | 3 days
+ TABLE
before do
set_non_working_days(next_monday.next_occurring(:wednesday))
@@ -1574,12 +1574,12 @@ RSpec.describe WorkPackages::ApplyWorkingDaysChangeJob do
end
context "when having multiple work packages following each other, and having days becoming non working days" do
- let_schedule(<<~CHART)
- days | MTWTFSS |
- wp1 | X▓▓XX | follows wp2
- wp2 | X ░░ | follows wp3
- wp3 | XXX ░░ |
- CHART
+ let_work_packages(<<~TABLE)
+ subject | MTWTFSS | scheduling mode | properties
+ wp1 | X▓▓XX | automatic | follows wp2
+ wp2 | X ░░ | automatic | follows wp3
+ wp3 | XXX ░░ | manual |
+ TABLE
let(:non_working_days) do
[
@@ -1600,12 +1600,12 @@ RSpec.describe WorkPackages::ApplyWorkingDaysChangeJob do
.to change { WorkPackage.pluck(:lock_version) }
.from([0, 0, 0])
.to([1, 1, 1])
- expect(WorkPackage.all).to match_schedule(<<~CHART)
- days | MTWTFSSmtwtfssmtwtfss |
- wp1 | ░░ ░░░ ░░ ░░░X▓▓X▓▓▓X |
- wp2 | ░░ ░░░ ░░X░░░ ░░ ░░░ |
- wp3 | X▓▓X▓▓▓X░░ ░░░ ░░ ░░░ |
- CHART
+ expect(WorkPackage.all).to match_table(<<~TABLE)
+ subject | MTWTFSSmtwtfssmtwtfss |
+ wp1 | ░░ ░░░ ░░ ░░░X▓▓X▓▓▓X |
+ wp2 | ░░ ░░░ ░░X░░░ ░░ ░░░ |
+ wp3 | X▓▓X▓▓▓X░░ ░░░ ░░ ░░░ |
+ TABLE
end
it_behaves_like "journal updates with cause" do
@@ -1631,12 +1631,12 @@ RSpec.describe WorkPackages::ApplyWorkingDaysChangeJob do
# * follower wp3 gets rescheduled and moves to next Monday
# * wp2 will move from Wednesday-Thursday to Thursday-nextMonday too and its followers will be rescheduled too
# * follower wp3 gets rescheduled *again* and moves to next Thursday
- let_schedule(<<~CHART)
- days | MTWTFSS |
- wp1 | X ░░ |
- wp2 | XX ░░ |
- wp3 | X░░ | follows wp1, follows wp2
- CHART
+ let_work_packages(<<~TABLE)
+ subject | MTWTFSS | scheduling mode | properties
+ wp1 | X ░░ | manual |
+ wp2 | XX ░░ | manual |
+ wp3 | X░░ | automatic | follows wp1, follows wp2
+ TABLE
let(:non_working_days) do
[
@@ -1655,12 +1655,12 @@ RSpec.describe WorkPackages::ApplyWorkingDaysChangeJob do
.to change { WorkPackage.order(:subject).pluck(:lock_version) }
.from([0, 0, 0])
.to([1, 1, 2])
- expect(WorkPackage.all).to match_schedule(<<~CHART)
- days | MTWTFSSmtwt |
- wp1 | ░░X░░░ ░░ |
- wp2 | ░░X▓▓▓X░░ |
- wp3 | ░░ ░░░ ░░X |
- CHART
+ expect(WorkPackage.all).to match_table(<<~TABLE)
+ subject | MTWTFSSmtwt |
+ wp1 | ░░X░░░ ░░ |
+ wp2 | ░░X▓▓▓X░░ |
+ wp3 | ░░ ░░░ ░░X |
+ TABLE
end
it_behaves_like "journal updates with cause" do
@@ -1677,12 +1677,12 @@ RSpec.describe WorkPackages::ApplyWorkingDaysChangeJob do
end
context "when having multiple work packages following each other, and having days becoming working days" do
- let_schedule(<<~CHART)
- days | MTWTFSSmtwtfssmtwtfss |
- wp1 | ░░ ░░░ ░░ ░░░X▓▓X▓▓▓X | follows wp2
- wp2 | ░░ ░░░ ░░X░░░ ░░ ░░░ | follows wp3
- wp3 | X▓▓X▓▓▓X░░ ░░░ ░░ ░░░ |
- CHART
+ let_work_packages(<<~TABLE)
+ subject | MTWTFSSmtwtfssmtwtfss | scheduling mode | properties
+ wp1 | ░░ ░░░ ░░ ░░░X▓▓X▓▓▓X | automatic | follows wp2
+ wp2 | ░░ ░░░ ░░X░░░ ░░ ░░░ | automatic | follows wp3
+ wp3 | X▓▓X▓▓▓X░░ ░░░ ░░ ░░░ | manual |
+ TABLE
let(:non_working_days) do
[
@@ -1704,12 +1704,12 @@ RSpec.describe WorkPackages::ApplyWorkingDaysChangeJob do
it "keeps the same start dates and updates them only once" do
subject
- expect(WorkPackage.all).to match_schedule(<<~CHART)
- days | MTWTFSSmtwtfssmtwtfss |
- wp1 | ░░ ░░XXX ░░ | follows wp2
- wp2 | ░░ X ░░ ░░ | follows wp3
- wp3 | XXX ░░ ░░ ░░ |
- CHART
+ expect(WorkPackage.all).to match_table(<<~TABLE)
+ subject | MTWTFSSmtwtfssmtwtfss | properties
+ wp1 | ░░ ░░XXX ░░ | follows wp2
+ wp2 | ░░ X ░░ ░░ | follows wp3
+ wp3 | XXX ░░ ░░ ░░ |
+ TABLE
expect(WorkPackage.pluck(:lock_version)).to all(be <= 1)
end
@@ -1730,12 +1730,12 @@ RSpec.describe WorkPackages::ApplyWorkingDaysChangeJob do
end
context "when having multiple work packages following each other and first one only has a due date" do
- let_schedule(<<~CHART)
- days | MTWTFSS |
- wp1 | X▓▓XX | follows wp2
- wp2 | XX ░░ | follows wp3
- wp3 | ] ░░ |
- CHART
+ let_work_packages(<<~TABLE)
+ subject | MTWTFSS | scheduling mode | properties
+ wp1 | X▓▓XX | automatic | follows wp2
+ wp2 | XX ░░ | automatic | follows wp3
+ wp3 | ] ░░ | manual |
+ TABLE
let(:non_working_days) do
[
@@ -1756,12 +1756,12 @@ RSpec.describe WorkPackages::ApplyWorkingDaysChangeJob do
.to change { WorkPackage.pluck(:lock_version) }
.from([0, 0, 0])
.to([1, 1, 1])
- expect(WorkPackage.all).to match_schedule(<<~CHART)
- days | MTWTFSSm t ssm t ssm |
- wp1 | ░░ ░░░ ░░ ░░░X▓▓X▓▓▓X |
- wp2 | ░░ ░░░X▓▓X░░░ ░░ ░░░ |
- wp3 | ░░]░░░ ░░ ░░░ ░░ ░░░ |
- CHART
+ expect(WorkPackage.all).to match_table(<<~TABLE)
+ subject | MTWTFSSm t ssm t ssm |
+ wp1 | ░░ ░░░ ░░ ░░░X▓▓X▓▓▓X |
+ wp2 | ░░ ░░░X▓▓X░░░ ░░ ░░░ |
+ wp3 | ░░]░░░ ░░ ░░░ ░░ ░░░ |
+ TABLE
end
it_behaves_like "journal updates with cause" do
@@ -1778,10 +1778,10 @@ RSpec.describe WorkPackages::ApplyWorkingDaysChangeJob do
end
context "when turning Sunday into a working day" do
- let_schedule(<<~CHART)
- days | MTWTFSSm |
+ let_work_packages(<<~TABLE)
+ subject | MTWTFSSm |
work_package | X▓▓X |
- CHART
+ TABLE
let!(:previous_non_working_days) { week_with_saturday_and_sunday_as_non_working_day }