Commit 8158b212 authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Merge branch 'fix-events-computing-for-milestone-change-events' into 'master'

Fix timebox charts events computing

See merge request gitlab-org/gitlab!65737
parents 5cbd4931 d6d9c48b
......@@ -62,7 +62,7 @@ class TimeboxReportService
handle_remove_timebox_event(event)
end
issue_state[:timebox] = event['value']
issue_state[:timebox] = event['action'] == ResourceTimeboxEvent.actions[:add] ? event['value'] : nil
end
def handle_add_timebox_event(event)
......
......@@ -289,6 +289,28 @@ RSpec.shared_examples 'timebox chart' do |timebox_type|
}
])
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
......@@ -317,4 +339,10 @@ RSpec.describe TimeboxReportService do
it_behaves_like 'timebox chart', 'iteration'
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
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