Commit f1e83fc2 authored by Shinya Maeda's avatar Shinya Maeda

Merge branch 'ali/add-pending-approval-count-to-protected-env-controller' into 'master'

Add required_approval_count to protected environments controller

See merge request gitlab-org/gitlab!79561
parents 5fcf206f 9ac1039d
...@@ -52,7 +52,11 @@ class Projects::ProtectedEnvironmentsController < Projects::ApplicationControlle ...@@ -52,7 +52,11 @@ class Projects::ProtectedEnvironmentsController < Projects::ApplicationControlle
end end
def protected_environment_params def protected_environment_params
params.require(:protected_environment).permit(:name, deploy_access_levels_attributes: deploy_access_level_attributes) params.require(:protected_environment).permit(
:name,
:required_approval_count,
deploy_access_levels_attributes: deploy_access_level_attributes
)
end end
def deploy_access_level_attributes def deploy_access_level_attributes
......
...@@ -13,7 +13,8 @@ RSpec.describe Projects::ProtectedEnvironmentsController do ...@@ -13,7 +13,8 @@ RSpec.describe Projects::ProtectedEnvironmentsController do
describe '#POST create' do describe '#POST create' do
let(:params) do let(:params) do
attributes_for(:protected_environment, attributes_for(:protected_environment,
deploy_access_levels_attributes: [{ access_level: maintainer_access }]) deploy_access_levels_attributes: [{ access_level: maintainer_access }],
required_approval_count: 1)
end end
subject do subject do
...@@ -93,7 +94,8 @@ RSpec.describe Projects::ProtectedEnvironmentsController do ...@@ -93,7 +94,8 @@ RSpec.describe Projects::ProtectedEnvironmentsController do
deploy_access_levels_attributes: [ deploy_access_levels_attributes: [
{ id: deploy_access_level.id, access_level: Gitlab::Access::DEVELOPER }, { id: deploy_access_level.id, access_level: Gitlab::Access::DEVELOPER },
{ access_level: maintainer_access } { access_level: maintainer_access }
] ],
required_approval_count: 3
} }
end end
...@@ -118,8 +120,9 @@ RSpec.describe Projects::ProtectedEnvironmentsController do ...@@ -118,8 +120,9 @@ RSpec.describe Projects::ProtectedEnvironmentsController do
expect(assigns(:protected_environment)).to eq(protected_environment) expect(assigns(:protected_environment)).to eq(protected_environment)
end end
it 'updates the protected environment' do it 'updates the protected environment', :aggregate_failures do
expect(protected_environment.deploy_access_levels.count).to eq(2) expect(protected_environment.deploy_access_levels.count).to eq(2)
expect(protected_environment.reload.required_approval_count).to eq(3)
end end
it 'is successful' do it 'is successful' do
......
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