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

Adapt test to manual scheduling being used when appropriate

Christophe Bliard9a72d03885ea
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 94e62e3e359..69c2cf506f7 100644
--- a/spec/requests/api/v3/work_packages/create_resource_spec.rb
+++ b/spec/requests/api/v3/work_packages/create_resource_spec.rb
@@ -193,10 +193,31 @@ RSpec.describe "API v3 Work package resource",
end
context "with false" do
- let(:parameters) { super().merge(scheduleManually: false) }
+ let(:parameters) do
+ super().merge(scheduleManually: false)
+ end
+
+ context "when the created work package has an indirect predecessor" do
+ let(:predecessor) { create(:work_package, project:) }
+ let(:parent) { create(:work_package, project:, schedule_manually: false) }
+ let(:parameters) do
+ super().merge(parent: parent)
+ end
+
+ before do
+ create(:follows_relation, from: parent, to: predecessor)
+ end
+
+ it "sets the scheduling mode to automatic (schedule_manually: false)" do
+ expect(work_package.schedule_manually).to be false
+ end
+ end
- it "sets the scheduling mode to automatic (schedule_manually: false)" do
- expect(work_package.schedule_manually).to be false
+ context "when the work package has no direct or indirect predecessors and no children" do
+ # TODO: should the API return an error here?
+ it "does not set the scheduling mode to automatic and keeps manual scheduling mode (schedule_manually: true)" do
+ expect(work_package.schedule_manually).to be true
+ end
end
end