Commit d6d9c48b authored by Alexandru Croitor's avatar Alexandru Croitor

Fix timebox charts events computing

When an issue was removed and then added back to same timebox
we were miss-counting the events. This should backfix the charts.

Changelog: fixed
EE: true
parent 1e1a10dd
...@@ -62,7 +62,7 @@ class TimeboxReportService ...@@ -62,7 +62,7 @@ class TimeboxReportService
handle_remove_timebox_event(event) handle_remove_timebox_event(event)
end end
issue_state[:timebox] = event['value'] issue_state[:timebox] = event['action'] == ResourceTimeboxEvent.actions[:add] ? event['value'] : nil
end end
def handle_add_timebox_event(event) def handle_add_timebox_event(event)
......
...@@ -289,6 +289,28 @@ RSpec.shared_examples 'timebox chart' do |timebox_type| ...@@ -289,6 +289,28 @@ RSpec.shared_examples 'timebox chart' do |timebox_type|
} }
]) ])
end end
context 'when timebox is removed and then added back' do
using RSpec::Parameterized::TableSyntax
where(:event_types, :scope_count) do
[:add, :add] | 1
[:remove, :remove] | 0
[:add, :add, :remove] | 0
[:add, :remove, :remove] | 0
[:add, :remove, :add] | 1
[:add, :remove, :remove, :add] | 1
[:add, :add, :remove, :add, :add] | 1
end
with_them do
it "updates the counts correspondingly" do
create_events(event_types, timebox_type)
expect(response.payload[:burnup_time_series].first&.dig(:scope_count).to_i).to eq(scope_count)
end
end
end
end end
end end
...@@ -317,4 +339,10 @@ RSpec.describe TimeboxReportService do ...@@ -317,4 +339,10 @@ RSpec.describe TimeboxReportService do
it_behaves_like 'timebox chart', 'iteration' it_behaves_like 'timebox chart', 'iteration'
end end
def create_events(event_types, timebox_type)
event_types.each_with_index do |event_type, index|
create(:"resource_#{timebox_type}_event", issue: issues[0], "#{timebox_type}" => timebox, action: event_type, created_at: timebox_start_date + 4.days + (index + 1).seconds)
end
end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment