Commit 81d4fc12 authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Merge branch...

Merge branch '29789-merge-request-approvers-in-list-sometimes-doesnt-show-correct-number' into 'master'

Resolve "Merge request approvers in list sometimes doesnt show correct number"

Closes #29789

See merge request gitlab-org/gitlab!23827
parents 925f3613 a40973ae
......@@ -11,6 +11,7 @@ module Approvable
approval_needed?
approved?
approvals_left
approvals_required
can_approve?
has_approved?
authors_can_approve?
......@@ -38,10 +39,6 @@ module Approvable
approvals.size
end
def approvals_required
[approvals_before_merge.to_i, target_project.approvals_before_merge.to_i].max
end
def approvals_before_merge
return unless approval_feature_available?
......
---
title: Correctly display the number of approvals for a merge request
merge_request: 23827
author:
type: fixed
......@@ -323,6 +323,15 @@ describe ApprovalState do
end
end
describe '#approvals_required' do
it "correctly sums the approvals" do
create_rule(approvals_required: 3)
create_rule(approvals_required: 10)
expect(subject.approvals_required).to eq(13)
end
end
describe '#approvers' do
it 'includes all approvers, including code owner and group members' do
create_rule(users: [approver1])
......
......@@ -684,30 +684,6 @@ describe MergeRequest do
end
end
describe '#approvals_required' do
where(:license_value, :db_value, :project_db_value, :expected) do
true | 5 | 6 | 6
true | 6 | 5 | 6
true | nil | 5 | 5
false | 5 | 6 | 0
false | nil | 5 | 0
end
with_them do
let(:merge_request) { build(:merge_request, approvals_before_merge: db_value) }
subject { merge_request.approvals_required }
before do
stub_licensed_features(merge_request_approvers: license_value)
merge_request.target_project.approvals_before_merge = project_db_value
end
it { is_expected.to eq(expected) }
end
end
describe '#mergeable?' do
let(:project) { create(:project) }
......
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