Feature flag for merge requestion push options

https://gitlab.com/gitlab-org/gitlab-ce/issues/43263
https://gitlab.com/gitlab-org/gitlab-ce/issues/53198
This commit is contained in:
Luke Duncalfe 2019-04-08 21:59:12 +12:00
parent e73f537cb5
commit 3c40c98e26
2 changed files with 18 additions and 2 deletions

View File

@ -264,8 +264,10 @@ module API
PostReceive.perform_async(params[:gl_repository], params[:identifier],
params[:changes], push_options.as_json)
mr_options = push_options.get(:merge_request)
output.merge!(process_mr_push_options(mr_options, project, user, params[:changes])) if mr_options.present?
if Feature.enabled?(:mr_push_options, default_enabled: true)
mr_options = push_options.get(:merge_request)
output.merge!(process_mr_push_options(mr_options, project, user, params[:changes])) if mr_options.present?
end
broadcast_message = BroadcastMessage.current&.last&.message
reference_counter_decreased = Gitlab::ReferenceCounter.new(params[:gl_repository]).decrease

View File

@ -995,6 +995,20 @@ describe API::Internal do
expect(json_response['warnings']).to eq('Error encountered with push options \'merge_request.create\': my error')
end
context 'when the feature is disabled' do
it 'does not invoke MergeRequests::PushOptionsHandlerService' do
Feature.disable(:mr_push_options)
expect(MergeRequests::PushOptionsHandlerService).to receive(:new)
expect do
post api('/internal/post_receive'), params: valid_params
end.not_to change { MergeRequest.count }
Feature.enable(:mr_push_options)
end
end
end
context 'broadcast message exists' do