Commit 71011b0a authored by Dmytro Zaporozhets (DZ)'s avatar Dmytro Zaporozhets (DZ)

Merge branch '323360-change-pagination-params' into 'master'

Remove pagination params from external approval rule creation

See merge request gitlab-org/gitlab!56328
parents 0f1c19fd 1e70bb03
...@@ -23,7 +23,6 @@ module API ...@@ -23,7 +23,6 @@ module API
requires :name, type: String, desc: 'The name of the rule' requires :name, type: String, desc: 'The name of the rule'
requires :external_url, type: String, desc: 'The URL to notify when MR receives new commits' requires :external_url, type: String, desc: 'The URL to notify when MR receives new commits'
optional :protected_branch_ids, type: Array[Integer], coerce_with: ::API::Validations::Types::CommaSeparatedToIntegerArray.coerce, desc: 'The protected branch ids for this rule' optional :protected_branch_ids, type: Array[Integer], coerce_with: ::API::Validations::Types::CommaSeparatedToIntegerArray.coerce, desc: 'The protected branch ids for this rule'
use :pagination
end end
desc 'Create a new external approval rule' do desc 'Create a new external approval rule' do
success ::API::Entities::ExternalApprovalRule success ::API::Entities::ExternalApprovalRule
...@@ -44,6 +43,9 @@ module API ...@@ -44,6 +43,9 @@ module API
desc 'List project\'s external approval rules' do desc 'List project\'s external approval rules' do
detail 'This feature is gated by the :ff_compliance_approval_gates feature flag.' detail 'This feature is gated by the :ff_compliance_approval_gates feature flag.'
end end
params do
use :pagination
end
get do get do
unauthorized! unless current_user.can?(:admin_project, @project) unauthorized! unless current_user.can?(:admin_project, @project)
......
...@@ -56,8 +56,11 @@ RSpec.describe ::API::ExternalApprovalRules do ...@@ -56,8 +56,11 @@ RSpec.describe ::API::ExternalApprovalRules do
create(:external_approval_rule) # Creating an orphaned rule to make sure project scoping works as expected create(:external_approval_rule) # Creating an orphaned rule to make sure project scoping works as expected
end end
it 'responds with expected JSON', :aggregate_failures do before do
stub_licensed_features(compliance_approval_gates: true) stub_licensed_features(compliance_approval_gates: true)
end
it 'responds with expected JSON', :aggregate_failures do
get api(collection_url, project.owner) get api(collection_url, project.owner)
expect(json_response.size).to eq(2) expect(json_response.size).to eq(2)
...@@ -65,6 +68,12 @@ RSpec.describe ::API::ExternalApprovalRules do ...@@ -65,6 +68,12 @@ RSpec.describe ::API::ExternalApprovalRules do
expect(json_response.map { |r| r['external_url'] }).to contain_exactly('http://rule1.example', 'https://rule2.example') expect(json_response.map { |r| r['external_url'] }).to contain_exactly('http://rule1.example', 'https://rule2.example')
end end
it 'paginates correctly' do
get api(collection_url, project.owner), params: { per_page: 1 }
expect_paginated_array_response([1])
end
context 'when feature is disabled, unlicensed or user has permission' do context 'when feature is disabled, unlicensed or user has permission' do
where(:licensed, :flag, :project_owner, :status) do where(:licensed, :flag, :project_owner, :status) do
false | false | false | :not_found false | false | false | :not_found
......
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