Commit 154bbe3d authored by Tetiana Chupryna's avatar Tetiana Chupryna

Properly check if license-check approved

parent 9e69466a
...@@ -245,7 +245,9 @@ module EE ...@@ -245,7 +245,9 @@ module EE
private private
def has_approved_license_check? 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 end
def missing_report_error(report_type) def missing_report_error(report_type)
......
...@@ -120,14 +120,20 @@ RSpec.describe MergeRequest do ...@@ -120,14 +120,20 @@ RSpec.describe MergeRequest do
end end
context 'with License-Check enabled' do 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 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 } it { is_expected.to be_truthy }
end end
context 'when rule is approved' do 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 } it { is_expected.to be_falsey }
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