Commit df4787f2 authored by James Lopez's avatar James Lopez

Merge branch '213435-optional-approvals-count' into 'master'

Resolve "Number of required approvals is counterintuitive on the merge request list"

See merge request gitlab-org/gitlab!32880
parents 1b841f49 8a6787cc
...@@ -165,6 +165,11 @@ class ApprovalState ...@@ -165,6 +165,11 @@ class ApprovalState
end end
end end
# This is the required + optional approval count
def total_approvals_count
approvals.size
end
private private
attr_reader :target_branch attr_reader :target_branch
......
...@@ -36,7 +36,7 @@ class ApprovalWrappedRule ...@@ -36,7 +36,7 @@ class ApprovalWrappedRule
filter_approvers(@approval_rule.approvers) filter_approvers(@approval_rule.approvers)
end end
# @return [Array<User>] all approvers related to this rule # @return [Array<User>] of users who have approved the merge request
# #
# This is dynamically calculated unless it is persisted as `approved_approvers`. # This is dynamically calculated unless it is persisted as `approved_approvers`.
# #
......
...@@ -17,6 +17,7 @@ module Approvable ...@@ -17,6 +17,7 @@ module Approvable
authors_can_approve? authors_can_approve?
committers_can_approve? committers_can_approve?
approvers_overwritten? approvers_overwritten?
total_approvals_count
}.freeze }.freeze
delegate(*FORWARDABLE_METHODS, to: :approval_state) delegate(*FORWARDABLE_METHODS, to: :approval_state)
......
...@@ -1607,4 +1607,17 @@ describe ApprovalState do ...@@ -1607,4 +1607,17 @@ describe ApprovalState do
end end
end end
end end
describe '#total_approvals_count' do
let(:rule) { create_rule(approvals_required: 1, rule_type: :any_approver, users: [approver1]) }
before do
create(:approval, merge_request: merge_request, user: rule.users.first)
create(:approval, merge_request: merge_request, user: approver2)
end
it 'returns the total number of approvals (required + optional)' do
expect(subject.total_approvals_count).to eq(2)
end
end
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