Commit 56ef4ec4 authored by Robert May's avatar Robert May

Update commented_by implementation

Next iteration of adding `commented_by` to the API. This
commit relocates where it's implemented, preparing to
fetch the real data.
parent bb340771
...@@ -74,6 +74,12 @@ class ApprovalWrappedRule ...@@ -74,6 +74,12 @@ class ApprovalWrappedRule
end end
end end
def commented_approvers
strong_memoize(:commented_approvers) do
[]
end
end
def approved? def approved?
strong_memoize(:approved) do strong_memoize(:approved) do
approvals_left <= 0 || unactioned_approvers.size <= 0 approvals_left <= 0 || unactioned_approvers.size <= 0
......
...@@ -9,6 +9,7 @@ module EE ...@@ -9,6 +9,7 @@ module EE
# To be removed in https://gitlab.com/gitlab-org/gitlab/issues/13574. # To be removed in https://gitlab.com/gitlab-org/gitlab/issues/13574.
class MergeRequestApprovalSettingRule < MergeRequestApprovalStateRule class MergeRequestApprovalSettingRule < MergeRequestApprovalStateRule
expose :approvers, using: ::API::Entities::UserBasic, override: true expose :approvers, using: ::API::Entities::UserBasic, override: true
expose :commented_approvers, as: :commented_by, using: ::API::Entities::UserBasic
end end
end end
end end
......
...@@ -7,8 +7,6 @@ module EE ...@@ -7,8 +7,6 @@ module EE
expose :code_owner expose :code_owner
expose :approved_approvers, as: :approved_by, using: ::API::Entities::UserBasic expose :approved_approvers, as: :approved_by, using: ::API::Entities::UserBasic
expose :approved?, as: :approved expose :approved?, as: :approved
expose :approved_approvers, as: :commented_by, using: ::API::Entities::UserBasic
end end
end end
end end
......
...@@ -138,6 +138,12 @@ RSpec.describe ApprovalWrappedRule do ...@@ -138,6 +138,12 @@ RSpec.describe ApprovalWrappedRule do
end end
end end
describe "#commented_approvers" do
it "returns an array" do
expect(subject.commented_approvers).to be_an(Array)
end
end
describe '#unactioned_approvers' do describe '#unactioned_approvers' do
context 'when some approvers has not approved yet' do context 'when some approvers has not approved yet' do
before do before do
......
...@@ -174,7 +174,7 @@ RSpec.describe API::MergeRequestApprovals do ...@@ -174,7 +174,7 @@ RSpec.describe API::MergeRequestApprovals do
expect(rule_response['name']).to eq('foo') expect(rule_response['name']).to eq('foo')
expect(rule_response['approvers'][0]['username']).to eq(approver.username) expect(rule_response['approvers'][0]['username']).to eq(approver.username)
expect(rule_response['approved_by'][0]['username']).to eq(approver.username) expect(rule_response['approved_by'][0]['username']).to eq(approver.username)
expect(rule_response['commented_by'][0]['username']).to eq(approver.username) expect(rule_response['commented_by']).to eq([])
expect(rule_response['source_rule']).to be_nil expect(rule_response['source_rule']).to be_nil
expect(rule_response['section']).to be_nil expect(rule_response['section']).to be_nil
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