Commit 3e47fbc1 authored by Stan Hu's avatar Stan Hu

Fix merges not working when project is not licensed for squash

Closes #3321
parent 0af97abd
......@@ -305,7 +305,7 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo
return :failed
end
merge_request_service = MergeRequests::MergeService.new(@project, current_user, merge_params)
merge_request_service = ::MergeRequests::MergeService.new(@project, current_user, merge_params)
unless merge_request_service.hooks_validation_pass?(@merge_request)
return :hook_validation_error
......@@ -313,7 +313,7 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo
return :sha_mismatch if params[:sha] != @merge_request.diff_head_sha
@merge_request.update(merge_error: nil, squash: merge_params[:squash])
@merge_request.update(merge_error: nil, squash: merge_params.fetch(:squash, false))
if params[:merge_when_pipeline_succeeds].present?
return :failed unless @merge_request.head_pipeline
......
---
title: Fix merges not working when project is not licensed for squash
merge_request:
author:
type: fixed
......@@ -293,6 +293,13 @@ describe Projects::MergeRequestsController do
expect(merge_request.reload.squash).to be_truthy
end
it 'merges even when squash is unavailable' do
stub_licensed_features(merge_request_squash: false)
merge_with_sha(squash: '1')
expect(merge_request.reload.squash).to be_falsey
end
end
context 'when squash is passed as 0' 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