Commit 984c0b83 authored by Sean McGivern's avatar Sean McGivern

Merge branch 'fix_statistic_calculation_logic' into 'master'

Fix vulnerability statistics calculation

See merge request gitlab-org/gitlab!38320
parents f96ec3a7 532075b9
......@@ -15,9 +15,9 @@ module Vulnerabilities
def update_with_note(vulnerability, params)
return false unless vulnerability.update(params)
SystemNoteService.change_vulnerability_state(vulnerability, @user) if vulnerability.state_previously_changed?
Vulnerabilities::Statistics::UpdateService.update_for(vulnerability)
Vulnerabilities::HistoricalStatistics::UpdateService.update_for(vulnerability.project)
SystemNoteService.change_vulnerability_state(vulnerability, @user) if vulnerability.state_previously_changed?
true
end
......
......@@ -21,8 +21,7 @@ RSpec.describe Vulnerabilities::ConfirmService do
project.add_developer(user)
end
it_behaves_like 'calls Vulnerabilities::Statistics::UpdateService'
it_behaves_like 'calls Vulnerabilities::HistoricalStatistics::UpdateService'
it_behaves_like 'calls vulnerability statistics utility services in order'
it 'confirms a vulnerability' do
Timecop.freeze do
......
......@@ -21,8 +21,7 @@ RSpec.describe Vulnerabilities::DismissService do
project.add_developer(user)
end
it_behaves_like 'calls Vulnerabilities::Statistics::UpdateService'
it_behaves_like 'calls Vulnerabilities::HistoricalStatistics::UpdateService'
it_behaves_like 'calls vulnerability statistics utility services in order'
it 'dismisses a vulnerability and its associated findings' do
Timecop.freeze do
......
......@@ -21,8 +21,7 @@ RSpec.describe Vulnerabilities::ResolveService do
project.add_developer(user)
end
it_behaves_like 'calls Vulnerabilities::Statistics::UpdateService'
it_behaves_like 'calls Vulnerabilities::HistoricalStatistics::UpdateService'
it_behaves_like 'calls vulnerability statistics utility services in order'
it 'resolves a vulnerability' do
Timecop.freeze do
......
# frozen_string_literal: true
RSpec.shared_examples 'calls vulnerability statistics utility services in order' do
before do
allow(Vulnerabilities::Statistics::UpdateService).to receive(:update_for)
allow(Vulnerabilities::HistoricalStatistics::UpdateService).to receive(:update_for)
allow(SystemNoteService).to receive(:change_vulnerability_state)
end
it 'calls the service classes in order' do
subject
expect(Vulnerabilities::Statistics::UpdateService).to have_received(:update_for).ordered
expect(Vulnerabilities::HistoricalStatistics::UpdateService).to have_received(:update_for).ordered
expect(SystemNoteService).to have_received(:change_vulnerability_state).ordered
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