Add feature-flag support

Returns error in MergeToRefService when
merge_to_tmp_merge_ref_path ff is disabled.
This commit is contained in:
Oswaldo Ferreira 2019-02-12 08:22:44 -02:00
parent 105212ce49
commit 4e16edbe0a
2 changed files with 12 additions and 1 deletions

View File

@ -34,7 +34,9 @@ module MergeRequests
def error_check!
error =
if !merge_method_supported?
if Feature.disabled?(:merge_to_tmp_merge_ref_path, project)
'Feature is not enabled'
elsif !merge_method_supported?
"#{project.human_merge_method} to #{target_ref} is currently not supported."
elsif !hooks_validation_pass?(merge_request)
hooks_validation_error(merge_request)

View File

@ -74,6 +74,15 @@ describe MergeRequests::MergeToRefService do
process_merge_to_ref
end
it 'returns error when feature is disabled' do
stub_feature_flags(merge_to_tmp_merge_ref_path: false)
result = service.execute(merge_request)
expect(result[:status]).to eq(:error)
expect(result[:message]).to eq('Feature is not enabled')
end
it 'returns an error when the failing to process the merge' do
allow(project.repository).to receive(:merge_to_ref).and_return(nil)