Commit 7af730a0 authored by Steffen Köhler's avatar Steffen Köhler Committed by Igor Drozdov

Fix calculation of given approvals

parent f62f3979
---
title: Fix number of approvals given calculation
merge_request: 28293
author: Steffen Köhler
type: fixed
...@@ -42,7 +42,7 @@ module Approvable ...@@ -42,7 +42,7 @@ module Approvable
end end
def approvals_given def approvals_given
approvals.size approvals_required - approvals_left
end end
def approvals_before_merge def approvals_before_merge
......
...@@ -27,6 +27,17 @@ describe Approvable do ...@@ -27,6 +27,17 @@ describe Approvable do
end end
end end
describe "#approvals_given" do
subject { merge_request.approvals_given }
it "returns the correct number of approvals given" do
approval_state = double("approval_state", approvals_required: 5, approvals_left: 3)
allow(merge_request).to receive(:approval_state).and_return(approval_state)
expect(subject).to eq(approval_state.approvals_required - approval_state.approvals_left)
end
end
described_class::FORWARDABLE_METHODS.each do |method| described_class::FORWARDABLE_METHODS.each do |method|
it { is_expected.to delegate_method(method).to(:approval_state) } it { is_expected.to delegate_method(method).to(:approval_state) }
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