Commit 394b57bc authored by Kerri Miller's avatar Kerri Miller

Expose boolean predicate methods in API

parent 0b6d6f9d
---
title: Ensure Project Approvals API casts to boolean
merge_request: 55492
author:
type: fixed
...@@ -7,11 +7,20 @@ module EE ...@@ -7,11 +7,20 @@ module EE
expose :approvers, using: EE::API::Entities::Approver expose :approvers, using: EE::API::Entities::Approver
expose :approver_groups, using: EE::API::Entities::ApproverGroup expose :approver_groups, using: EE::API::Entities::ApproverGroup
expose :approvals_before_merge expose :approvals_before_merge
expose :reset_approvals_on_push expose :reset_approvals_on_push
expose :disable_overriding_approvers_per_merge_request
expose :merge_requests_author_approval expose :disable_overriding_approvers_per_merge_request?,
expose :merge_requests_disable_committers_approval as: :disable_overriding_approvers_per_merge_request
expose :require_password_to_approve
expose :merge_requests_author_approval?,
as: :merge_requests_author_approval
expose :merge_requests_disable_committers_approval?,
as: :merge_requests_disable_committers_approval
expose :require_password_to_approve?,
as: :require_password_to_approve
end end
end end
end end
......
...@@ -20,6 +20,18 @@ RSpec.describe API::ProjectApprovals do ...@@ -20,6 +20,18 @@ RSpec.describe API::ProjectApprovals do
get api(url, user) get api(url, user)
end end
it 'does not return null values for unmodified boolean fields' do
expect(project.disable_overriding_approvers_per_merge_request).to be_nil
expect(project.merge_requests_author_approval).to be_nil
expect(project.merge_requests_disable_committers_approval).to be_nil
expect(project.require_password_to_approve).to be_nil
expect(json_response["disable_overriding_approvers_per_merge_request"]).to be false
expect(json_response["merge_requests_author_approval"]).to be false
expect(json_response["merge_requests_disable_committers_approval"]).to be false
expect(json_response["require_password_to_approve"]).to be false
end
it 'returns 200 status' do it 'returns 200 status' do
expect(response).to have_gitlab_http_status(:ok) expect(response).to have_gitlab_http_status(:ok)
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