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

Add acceptance specs

Christophe Bliardcdf680961d15
diff --git a/spec/models/day_spec.rb b/spec/models/day_spec.rb
index 2eaad532735..46dc154a248 100644
--- a/spec/models/day_spec.rb
+++ b/spec/models/day_spec.rb
@@ -103,7 +103,7 @@ describe Day, type: :model do
end
context 'when the week day is working' do
- shared_let(:working_days) { reset_working_week_days('saturday') }
+ shared_let(:working_days) { set_work_week('saturday') }
it 'is true' do
expect(subject.working).to be_truthy
diff --git a/spec/support/settings.rb b/spec/support/settings.rb
index 85529389283..63eeffad9a0 100644
--- a/spec/support/settings.rb
+++ b/spec/support/settings.rb
@@ -58,7 +58,7 @@ def set_week_days(*days, working: true)
end
end
-def reset_working_week_days(*days)
+def set_work_week(*days)
week_days = get_week_days(*days)
Setting.working_days = week_days
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 cc267bf9727..ba051eb10b4 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
@@ -122,8 +122,29 @@ RSpec.describe WorkPackages::ApplyWorkingDaysChangeJob do
end
end
+ context 'when a follower has a predecessor with delay covering a day that is now a non-working day' do
+ let_schedule(<<~CHART)
+ days | MTWTFSS |
+ predecessor | XX |
+ follower | X | follows predecessor with delay 1
+ CHART
+
+ before do
+ set_non_working_week_days('wednesday')
+ end
+
+ it 'moves the follower start date to keep the delay to 1 day' do
+ job.perform_now(user_id: user.id)
+ expect(WorkPackage.all).to match_schedule(<<~CHART)
+ days | MTWTFSS |
+ predecessor | XX |
+ follower | X |
+ CHART
+ end
+ end
+
context 'when a follower has a predecessor with dates covering a day that is now a working day' do
- let!(:week) { reset_working_week_days('monday', 'tuesday', 'thursday', 'friday') }
+ let!(:week) { set_work_week('monday', 'tuesday', 'thursday', 'friday') }
let_schedule(<<~CHART)
days | MTWTFSS |
@@ -145,8 +166,8 @@ RSpec.describe WorkPackages::ApplyWorkingDaysChangeJob do
end
end
- xcontext 'when a follower has a predecessor with a non-working day between them that is now a working day' do
- let!(:week) { reset_working_week_days('monday', 'tuesday', 'thursday', 'friday') }
+ context 'when a follower has a predecessor with a non-working day between them that is now a working day' do
+ let!(:week) { set_work_week('monday', 'tuesday', 'thursday', 'friday') }
let_schedule(<<~CHART)
days | MTWTFSS |
@@ -158,12 +179,12 @@ RSpec.describe WorkPackages::ApplyWorkingDaysChangeJob do
set_working_week_days('wednesday')
end
- it 'moves the follower start date one day back to keep the same gap between them' do
+ it 'does not move the follower' do
job.perform_now(user_id: user.id)
expect(WorkPackage.all).to match_schedule(<<~CHART)
days | MTWTFSS |
predecessor | XX |
- follower | XX |
+ follower | XX |
CHART
end
end
@@ -229,8 +250,8 @@ RSpec.describe WorkPackages::ApplyWorkingDaysChangeJob do
end
end
- xcontext 'when having multiple work packages following each other, and having days becoming working days' do
- let!(:week) { reset_working_week_days('monday', 'thursday') }
+ context 'when having multiple work packages following each other, and having days becoming working days' do
+ let!(:week) { set_work_week('monday', 'thursday') }
let_schedule(<<~CHART)
days | MTWTFSSmtwtfssmtwtfss |
@@ -243,15 +264,15 @@ RSpec.describe WorkPackages::ApplyWorkingDaysChangeJob do
set_working_week_days('tuesday', 'wednesday', 'friday')
end
- it 'updates them only once' do
+ it 'keeps the same start dates and updates them only once' do
job.perform_now(user_id: user.id)
expect(WorkPackage.all).to match_schedule(<<~CHART)
- days | MTWTFSSmt |
- wp1 | X..XX |
- wp2 | X |
- wp3 | XXX |
+ days | MTWTFSSmtwtfssmtwtfss |
+ wp1 | XXX | follows wp2
+ wp2 | X | follows wp3
+ wp3 | XXX |
CHART
- expect(WorkPackage.pluck(:lock_version)).to all(be_less_or_equal_than(1))
+ expect(WorkPackage.pluck(:lock_version)).to all(be <= 1)
end
end