Skip to content

Commit

Permalink
Adapt update_ancestors feature spec expectations
Browse files Browse the repository at this point in the history
We now expect the derived_done_ratio to be updated instead of the
parent's own done_ratio.
  • Loading branch information
aaron-contreras committed Jan 30, 2024
1 parent be8987f commit f89e4b7
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions spec/features/work_packages/update_ancestors_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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'))

Expand All @@ -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

Expand All @@ -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'))
Expand All @@ -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

0 comments on commit f89e4b7

Please sign in to comment.