Commit 06253747 authored by Can Eldem's avatar Can Eldem Committed by Rémy Coutable

Invalidate comparison cache when licenses approved or blacklisted

parent a9e8a9e3
......@@ -43,4 +43,8 @@ class SoftwareLicensePolicy < ApplicationRecord
end
delegate :name, to: :software_license
def self.workaround_cache_key
pluck(:id, :approval_status).flatten
end
end
......@@ -13,5 +13,11 @@ module Ci
def get_report(pipeline)
pipeline&.license_scanning_report
end
private
def key(base_pipeline, head_pipeline)
super(base_pipeline, head_pipeline) + project.software_license_policies.workaround_cache_key
end
end
end
......@@ -453,6 +453,18 @@ describe MergeRequest do
subject
end
context 'cache key includes sofware license policies' do
let!(:license_1) { create(:software_license_policy, project: project) }
let!(:license_2) { create(:software_license_policy, project: project) }
it 'returns key with license information' do
expect_any_instance_of(Ci::CompareLicenseScanningReportsService)
.to receive(:execute).with(base_pipeline, head_pipeline).and_call_original
expect(subject[:key]).to include(*[license_1.id, license_1.approval_status, license_2.id, license_2.approval_status])
end
end
context 'when cached results is not latest' do
before do
allow_any_instance_of(Ci::CompareLicenseScanningReportsService)
......
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