Skip to content

Commit

Permalink
Merge pull request #15716 from opf/chore/merge_table_helpers_together
Browse files Browse the repository at this point in the history
Merge table helpers and schedule helpers together
  • Loading branch information
cbliard authored Nov 21, 2024
2 parents aad69cd + 020e8df commit 066083e
Show file tree
Hide file tree
Showing 34 changed files with 1,535 additions and 243 deletions.
10 changes: 5 additions & 5 deletions config/environments/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
# See COPYRIGHT and LICENSE files for more details.
#++

require 'active_support/core_ext/integer/time'
require "active_support/core_ext/integer/time"

# The test environment is used exclusively to run your application's
# test suite. You never need to work with it otherwise. Remember that
Expand All @@ -52,7 +52,7 @@

# Configure public file server for tests with Cache-Control for performance.
config.public_file_server.enabled = true
config.public_file_server.headers = { 'Cache-Control' => 'public, max-age=3600' }
config.public_file_server.headers = { "Cache-Control" => "public, max-age=3600" }

# Show full error reports and disable caching.
config.consider_all_requests_local = true
Expand All @@ -75,11 +75,11 @@
config.action_mailer.delivery_method = :test

# Silence deprecations early on for testing on CI
deprecators.silenced = ENV['CI'].present?
deprecators.silenced = ENV["CI"].present?

# Print deprecation notices to the stderr.
config.active_support.deprecation =
if ENV['CI']
if ENV["CI"]
:silence
else
:stderr
Expand Down Expand Up @@ -114,7 +114,7 @@
# Use in-memory store for testing
Rack::Attack.cache.store = ActiveSupport::Cache::MemoryStore.new

if ENV['TEST_ENV_NUMBER']
if ENV["TEST_ENV_NUMBER"]
assets_cache_path = Rails.root.join("tmp/cache/assets/paralleltests#{ENV['TEST_ENV_NUMBER']}")
config.assets.cache = Sprockets::Cache::FileStore.new(assets_cache_path)
end
Expand Down
6 changes: 3 additions & 3 deletions spec/controllers/statuses_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@

perform_enqueued_jobs

expect_work_packages([parent, child, other_child], <<~TABLE)
expect_work_packages_after_reload([parent, child, other_child], <<~TABLE)
subject | status | work | remaining work | % complete | ∑ work | ∑ remaining work | ∑ % complete
parent | New | | | | 10h | 10h | 0%
child | Rejected | 10h | 5h | 50% | | |
Expand Down Expand Up @@ -245,7 +245,7 @@

perform_enqueued_jobs

expect_work_packages([parent, child, other_child], <<~TABLE)
expect_work_packages_after_reload([parent, child, other_child], <<~TABLE)
subject | status | work | remaining work | % complete | ∑ work | ∑ remaining work | ∑ % complete
parent | New | | | 0% | 10h | 10h | 0%
child | Rejected | 10h | 3h | 70% | | |
Expand All @@ -271,7 +271,7 @@

perform_enqueued_jobs

expect_work_packages([parent, child, other_child], <<~TABLE)
expect_work_packages_after_reload([parent, child, other_child], <<~TABLE)
subject | status | work | remaining work | % complete | ∑ work | ∑ remaining work | ∑ % complete
parent | New | | | 0% | 10h | 10h | 0%
child | Rejected | 10h | 6h | 40% | | |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
end

it "removes totals from childless work packages" do
expect_work_packages(table_work_packages.map(&:reload), <<~TABLE)
expect_work_packages_after_reload(table_work_packages, <<~TABLE)
hierarchy | work | remaining work | % complete | ∑ work | ∑ remaining work | ∑ % complete
wp totals set | 5h | 3h | 40% | | |
wp only pc set | | | 60% | | |
Expand Down
5 changes: 2 additions & 3 deletions spec/migrations/update_progress_calculation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ def expect_migrates(from:, to:)

run_migration

table.work_packages.map(&:reload)
expect_work_packages(table.work_packages, to)
expect_work_packages_after_reload(table.work_packages, to)

table.work_packages
end
Expand Down Expand Up @@ -829,7 +828,7 @@ def expect_migrates(from:, to:)
end

it "fixes the total values and sets ∑ % complete to nil (not 0) and keeps % complete (unless wrong)" do
expect_work_packages(table_work_packages.map(&:reload), <<~TABLE)
expect_work_packages_after_reload(table_work_packages, <<~TABLE)
subject | work | remaining work | % complete | ∑ work | ∑ remaining work | ∑ % complete |
wp zero | | | 0 | | | |
wp correct | 100h | 50h | 50 | 100h | 50h | 50 |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@

context "with a single successor" do
context "when moving successor will cover non-working days" do
let_schedule(<<~CHART)
days | MTWTFSS |
let_work_packages(<<~CHART)
subject | MTWTFSS | properties
work_package | XX |
follower | XXX | follows work_package
CHART
Expand All @@ -56,8 +56,8 @@
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, <<~CHART)
subject | MTWTFSS |
work_package | XXXX |
follower | X..XX |
CHART
Expand Down
16 changes: 8 additions & 8 deletions spec/services/work_packages/update_ancestors_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def call_update_ancestors_service(work_package)
set_attributes_on(child, field => value)
call_update_ancestors_service(child)

expect_work_packages([parent, child], <<~TABLE)
expect_work_packages_after_reload([parent, child], <<~TABLE)
| subject | status | work | ∑ work | remaining work | ∑ remaining work | % complete | ∑ % complete |
| parent | Open | 10h | 15h | 10h | 10h | 0% | 33% |
| child | Closed | 5h | | 0h | | 100% | |
Expand All @@ -95,7 +95,7 @@ def call_update_ancestors_service(work_package)
end

it "still recomputes child remaining work and updates ancestors total % complete excluding it" do
expect_work_packages([parent, child], <<~TABLE)
expect_work_packages_after_reload([parent, child], <<~TABLE)
| subject | status | work | ∑ work | remaining work | ∑ remaining work | % complete | ∑ % complete |
| parent | Open | 10h | 10h | 10h | 10h | 0% | 0% |
| child | Rejected | 5h | | 4h | | 20% | |
Expand All @@ -119,7 +119,7 @@ def call_update_ancestors_service(work_package)
end

it "sets parent total % complete to 100% and its total remaining work to 0h" do
expect_work_packages(table_work_packages, <<~TABLE)
expect_work_packages_after_reload(table_work_packages, <<~TABLE)
hierarchy | status | work | ∑ work | remaining work | ∑ remaining work | % complete | ∑ % complete
parent | Open | | 15h | | 0h | 0% | 100%
child1 | Closed | 10h | | 0h | | 100% |
Expand Down Expand Up @@ -386,7 +386,7 @@ def call_update_ancestors_service(work_package)

it "updates the totals of the ancestors" do
subject
expect_work_packages([grandparent, parent, sibling, work_package], <<~TABLE)
expect_work_packages_after_reload([grandparent, parent, sibling, work_package], <<~TABLE)
hierarchy | work | remaining work | % complete | ∑ work | ∑ remaining work | ∑ % complete
grandparent | 3h | 1.5h | 50% | 13h | 5h | 62%
parent | 3h | 0h | 100% | 10h | 3.5h | 65%
Expand Down Expand Up @@ -447,7 +447,7 @@ def call_update_ancestors_service(work_package)

it "updates the totals of the ancestors" do
subject
expect_work_packages([grandparent, parent, work_package], <<~TABLE)
expect_work_packages_after_reload([grandparent, parent, work_package], <<~TABLE)
hierarchy | work | remaining work | % complete | ∑ work | ∑ remaining work | ∑ % complete
grandparent | | | | 10h | 5h | 50%
parent | 3h | 1.5h | 50% | 10h | 5h | 50%
Expand Down Expand Up @@ -494,7 +494,7 @@ def call_update_ancestors_service(work_package)

it "updates the totals of the new parent and the former parent" do
subject
expect_work_packages([grandparent, old_parent, new_parent, work_package], <<~TABLE)
expect_work_packages_after_reload([grandparent, old_parent, new_parent, work_package], <<~TABLE)
hierarchy | work | remaining work | % complete | ∑ work | ∑ remaining work | ∑ % complete
grandparent | | | | 10h | 2h | 80%
old parent | | | | | |
Expand Down Expand Up @@ -597,7 +597,7 @@ def call_update_ancestors_service(work_package)
it "does not update the parent total work" do
expect(call_result).to be_success
expect(call_result.dependent_results).to be_empty
expect_work_packages([parent.reload], <<~TABLE)
expect_work_packages_after_reload([parent], <<~TABLE)
subject | total work |
parent | |
TABLE
Expand Down Expand Up @@ -693,7 +693,7 @@ def call_update_ancestors_service(work_package)
it "does not update the parent total remaining work" do
expect(call_result).to be_success
expect(call_result.dependent_results).to be_empty
expect_work_packages([parent.reload], <<~TABLE)
expect_work_packages_after_reload([parent], <<~TABLE)
subject | total remaining work
parent |
TABLE
Expand Down
Loading

0 comments on commit 066083e

Please sign in to comment.