From f89e4b7a90ea83d57d6fb65fb3446593775f9507 Mon Sep 17 00:00:00 2001 From: Aaron Contreras Date: Tue, 30 Jan 2024 12:17:26 -0500 Subject: [PATCH] Adapt update_ancestors feature spec expectations We now expect the derived_done_ratio to be updated instead of the parent's own done_ratio. --- .../work_packages/update_ancestors_spec.rb | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/spec/features/work_packages/update_ancestors_spec.rb b/spec/features/work_packages/update_ancestors_spec.rb index 2a3b872f99b1..9b679ede53ef 100644 --- a/spec/features/work_packages/update_ancestors_spec.rb +++ b/spec/features/work_packages/update_ancestors_spec.rb @@ -102,12 +102,12 @@ end context 'when changing a child work and remaining work values', retry: 2 do - it 'updates the parent work, remaining work, and % complete values' do + it "updates the derived parent work, remaining work, and % complete values" do expect do wp_table.update_work_package_attributes(child, estimatedTime: child.estimated_hours + 1) parent.reload end.to change(parent, :derived_estimated_hours).by(1) - .and change(parent, :done_ratio).to(35) # 7h at 50% and 3h at 0% => 35% complete for 10h + .and change(parent, :derived_done_ratio).to(35) # 7h at 50% and 3h at 0% => 35% complete for 10h expect do wp_table.update_work_package_attributes(child, remainingTime: child.remaining_hours + 2) parent.reload @@ -116,37 +116,37 @@ end context 'when changing a child % complete value' do - it 'updates the parent % complete value' do + it 'updates the derived parent % complete value' do expect do wp_table.update_work_package_attributes(child, percentageDone: 100) parent.reload - end.to change(parent, :done_ratio).to(67) # 6h at 100% and 3h at 0% => 67% complete for 9h + end.to change(parent, :derived_done_ratio).to(67) # 6h at 100% and 3h at 0% => 67% complete for 9h end end context 'when setting a child status to closed' do - it 'considers child % complete to be 100% and updates the parent % complete value accordingly' do + it 'considers child % complete to be 100% and updates the derived parent % complete value accordingly' do expect do wp_table.update_work_package_attributes(child, status: 'Closed') parent.reload - end.to change(parent, :done_ratio).to(67) # 6h at 100% and 3h at 0% => 67% complete for 9h + end.to change(parent, :derived_done_ratio).to(67) # 6h at 100% and 3h at 0% => 67% complete for 9h end end context 'when deleting a child' do - it 'updates the parent work, remaining work, and % complete values' do + it 'updates the derived parent work, remaining work, and % complete values' do context_menu = wp_table.open_context_menu_for(second_child) context_menu.choose_delete_and_confirm_deletion parent.reload expect(parent.derived_estimated_hours).to eq([parent, child].pluck(:estimated_hours).sum) expect(parent.derived_remaining_hours).to eq([parent, child].pluck(:remaining_hours).sum) - expect(parent.done_ratio).to eq(child.done_ratio) + expect(parent.derived_done_ratio).to eq(child.done_ratio) end end context 'when adding a new child' do - it 'updates the parent work, remaining work, and % complete values' do + it 'updates the derived parent work, remaining work, and % complete values' do context_menu = wp_table.open_context_menu_for(parent) context_menu.choose(I18n.t('js.relation_buttons.add_new_child')) @@ -161,7 +161,7 @@ expect(parent.derived_remaining_hours).to eq([parent, child, second_child, new_child].pluck(:remaining_hours).sum) # child + second child + new child => parent # 6h at 50% + 3h at 0% + 1h at 0% => 30% complete for 10h - expect(parent.done_ratio).to eq(30) + expect(parent.derived_done_ratio).to eq(30) end end @@ -174,7 +174,7 @@ parent.reload expect(parent.derived_estimated_hours).to eq([parent, child].pluck(:estimated_hours).sum) expect(parent.derived_remaining_hours).to eq([parent, child].pluck(:remaining_hours).sum) - expect(parent.done_ratio).to eq(child.done_ratio) + expect(parent.derived_done_ratio).to eq(child.done_ratio) context_menu = wp_table.open_context_menu_for(second_child) context_menu.choose(I18n.t('js.relation_buttons.hierarchy_indent')) @@ -185,7 +185,7 @@ expect(parent.derived_remaining_hours).to eq([parent, child, second_child].pluck(:remaining_hours).sum) # child + second child => parent # 6h at 50% + 3h at 0% => 33% complete for 9h - expect(parent.done_ratio).to eq(33) + expect(parent.derived_done_ratio).to eq(33) end end end