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 another test case

Christophe Bliard0e26f337ff85
diff --git a/spec/services/work_packages/set_attributes_service/derive_progress_values_work_based_spec.rb b/spec/services/work_packages/set_attributes_service/derive_progress_values_work_based_spec.rb
index 3a617789738..a2b37d583e1 100644
--- a/spec/services/work_packages/set_attributes_service/derive_progress_values_work_based_spec.rb
+++ b/spec/services/work_packages/set_attributes_service/derive_progress_values_work_based_spec.rb
@@ -232,7 +232,6 @@ RSpec.describe WorkPackages::SetAttributesService::DeriveProgressValuesWorkBased
context "when work is changed and remaining work is unset" do
let(:set_attributes) { { estimated_hours: 8.0, remaining_hours: nil } }
- let(:expected_derived_attributes) { set_attributes.dup }
let(:expected_kept_attributes) { %w[done_ratio] }
include_examples "update progress values",
@@ -240,6 +239,14 @@ RSpec.describe WorkPackages::SetAttributesService::DeriveProgressValuesWorkBased
"(error state to be detected by contract)"
end
+ context "when work is set to the same value and remaining work is changed" do
+ let(:set_attributes) { { estimated_hours: 10.0, remaining_hours: 1.0 } }
+ let(:expected_derived_attributes) { { done_ratio: 90 } }
+
+ include_examples "update progress values",
+ description: "% complete is updated accordingly"
+ end
+
context "when work is increased and remaining work is set to its current value (to prevent it from being increased)" do
# work changed by +10h
let(:set_attributes) { { estimated_hours: 10.0 + 10.0, remaining_hours: 3 } }
@@ -380,7 +387,6 @@ RSpec.describe WorkPackages::SetAttributesService::DeriveProgressValuesWorkBased
context "when work is changed and remaining work is unset" do
let(:set_attributes) { { estimated_hours: 10.0, remaining_hours: nil } }
- let(:expected_derived_attributes) { set_attributes.dup }
let(:expected_kept_attributes) { %w[done_ratio] }
include_examples "update progress values",
@@ -507,7 +513,6 @@ RSpec.describe WorkPackages::SetAttributesService::DeriveProgressValuesWorkBased
context "when work is set and remaining work is unset" do
let(:set_attributes) { { estimated_hours: 10.0, remaining_hours: nil } }
- let(:expected_derived_attributes) { set_attributes.dup }
let(:expected_kept_attributes) { %w[done_ratio] }
include_examples "update progress values",
@@ -577,7 +582,6 @@ RSpec.describe WorkPackages::SetAttributesService::DeriveProgressValuesWorkBased
context "when remaining work is set and work is unset" do
let(:set_attributes) { { estimated_hours: nil, remaining_hours: 6.7 } }
- let(:expected_derived_attributes) { set_attributes.dup }
let(:expected_kept_attributes) { %w[done_ratio] }
include_examples "update progress values",