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 a test when all hierarchy is excluded from totals

Christophe Bliard0f9be1ba41d6
diff --git a/spec/workers/work_packages/progress/apply_statuses_change_job_spec.rb b/spec/workers/work_packages/progress/apply_statuses_change_job_spec.rb
index dbcf01d1403..729b347784f 100644
--- a/spec/workers/work_packages/progress/apply_statuses_change_job_spec.rb
+++ b/spec/workers/work_packages/progress/apply_statuses_change_job_spec.rb
@@ -132,6 +132,21 @@ RSpec.describe WorkPackages::Progress::ApplyStatusesChangeJob,
)
end
+ it "removes all totals when all work packages of the hierarchy are excluded" do
+ expect_performing_job_changes(
+ from: <<~TABLE,
+ hierarchy | status | work | remaining work | % complete | ∑ work | ∑ remaining work | ∑ % complete
+ parent | Excluded | 10h | 3h | 70% | 20h | 5h | 75%
+ child | Excluded | 10h | 2h | 50% | | |
+ TABLE
+ to: <<~TABLE
+ subject | status | work | remaining work | % complete | ∑ work | ∑ remaining work | ∑ % complete
+ parent | Excluded | 10h | 3h | 70% | | |
+ child | Excluded | 10h | 2h | 50% | | |
+ TABLE
+ )
+ end
+
it "keeps the totals unset if work, remaining work, and % complete are all nil" do
expect_performing_job_changes(
from: <<~TABLE,
diff --git a/spec/workers/work_packages/progress/apply_total_percent_complete_mode_change_job_spec.rb b/spec/workers/work_packages/progress/apply_total_percent_complete_mode_change_job_spec.rb
index 5e393754f54..63527a3a1a2 100644
--- a/spec/workers/work_packages/progress/apply_total_percent_complete_mode_change_job_spec.rb
+++ b/spec/workers/work_packages/progress/apply_total_percent_complete_mode_change_job_spec.rb
@@ -212,6 +212,24 @@ RSpec.describe WorkPackages::Progress::ApplyTotalPercentCompleteModeChangeJob do
end
end
+ context "when all work packages of the hierarchy are excluded" do
+ it "removes all totals" do
+ expect_performing_job_changes(
+ mode: "work_weighted_average",
+ from: <<~TABLE,
+ hierarchy | status | work | remaining work | % complete | ∑ % complete
+ parent | Excluded | 40h | 12h | 70% | 72%
+ child | Excluded | 10h | 2h | 80% |
+ TABLE
+ to: <<~TABLE
+ subject | status | work | remaining work | % complete | ∑ % complete
+ parent | Excluded | 40h | 12h | 70% |
+ child | Excluded | 10h | 2h | 80% |
+ TABLE
+ )
+ end
+ end
+
describe "journal entries" do
# rubocop:disable RSpec/ExampleLength
it "creates journal entries for the modified work packages" do
@@ -396,6 +414,24 @@ RSpec.describe WorkPackages::Progress::ApplyTotalPercentCompleteModeChangeJob do
end
end
+ context "when all work packages of the hierarchy are excluded" do
+ it "removes all totals" do
+ expect_performing_job_changes(
+ mode: "simple_average",
+ from: <<~TABLE,
+ hierarchy | status | % complete | ∑ % complete
+ parent | Excluded | 0% | 0%
+ child | Excluded | 0% |
+ TABLE
+ to: <<~TABLE
+ subject | status | % complete | ∑ % complete
+ parent | Excluded | 0% |
+ child | Excluded | 0% |
+ TABLE
+ )
+ end
+ end
+
describe "journal entries" do
# rubocop:disable RSpec/ExampleLength
it "creates journal entries for the modified work packages" do