Commit 9752a3c8 authored by Stan Hu's avatar Stan Hu

Merge branch '215913-properly-check-for-approve' into 'master'

Properly check if license-check approved

See merge request gitlab-org/gitlab!37097
parents eba45673 154bbe3d
......@@ -245,7 +245,9 @@ module EE
private
def has_approved_license_check?
approval_rules.license_compliance.last&.approvals_required == 0
if rule = approval_rules.license_compliance.last
ApprovalWrappedRule.wrap(self, rule).approved?
end
end
def missing_report_error(report_type)
......
......@@ -120,14 +120,20 @@ RSpec.describe MergeRequest do
end
context 'with License-Check enabled' do
let!(:license_check) { create(:report_approver_rule, :license_scanning, merge_request: merge_request) }
context 'when rule is not approved' do
let!(:license_check) { create(:report_approver_rule, :license_scanning, merge_request: merge_request, approvals_required: 1) }
before do
allow_any_instance_of(ApprovalWrappedRule).to receive(:approved?).and_return(false)
end
it { is_expected.to be_truthy }
end
context 'when rule is approved' do
let!(:license_check) { create(:report_approver_rule, :license_scanning, merge_request: merge_request, approvals_required: 0) }
before do
allow_any_instance_of(ApprovalWrappedRule).to receive(:approved?).and_return(true)
end
it { is_expected.to be_falsey }
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