Commit ccbd665a authored by Sean McGivern's avatar Sean McGivern

Merge branch 'fix/29125-ee' into 'master'

Display custom hook error messages when automatic merge is enabled

Closes gitlab-ce#29125

See merge request !1670
parents 5ba1137c ab5cc440
......@@ -179,7 +179,7 @@ import MiniPipelineGraph from './mini_pipeline_graph_dropdown';
$('.ci-widget-fetching').show();
return $.getJSON(this.opts.ci_status_url, (function(_this) {
return function(data) {
var message, status, title;
var message, status, title, callback;
_this.status = data.status;
_this.hasCi = data.has_ci;
_this.updateMergeButton(_this.status, _this.hasCi);
......@@ -201,6 +201,12 @@ import MiniPipelineGraph from './mini_pipeline_graph_dropdown';
_this.opts.ci_sha = data.sha;
_this.updateCommitUrls(data.sha);
}
if (data.status === "success" || data.status === "failed") {
callback = function() {
return _this.getMergeStatus();
};
return setTimeout(callback, 2000);
}
if (showNotification && data.status) {
status = _this.ciLabelForStatus(data.status);
if (status === "preparing") {
......
......@@ -27,14 +27,16 @@
= render 'projects/merge_requests/widget/open/conflicts'
- elsif @merge_request.work_in_progress?
= render 'projects/merge_requests/widget/open/wip'
- elsif @merge_request.should_be_rebased?
= render 'projects/merge_requests/widget/open/rebase'
- elsif @merge_request.merge_when_pipeline_succeeds? && @merge_request.merge_error.present?
= render 'projects/merge_requests/widget/open/error'
- elsif @merge_request.merge_when_pipeline_succeeds?
= render 'projects/merge_requests/widget/open/merge_when_pipeline_succeeds'
- elsif !@merge_request.can_be_merged_by?(current_user)
= render 'projects/merge_requests/widget/open/not_allowed'
- elsif !@merge_request.mergeable_ci_state? && (@pipeline.failed? || @pipeline.canceled?)
= render 'projects/merge_requests/widget/open/build_failed'
- elsif @merge_request.should_be_rebased?
= render 'projects/merge_requests/widget/open/rebase'
- elsif !@merge_request.mergeable_discussions_state?
= render 'projects/merge_requests/widget/open/unresolved_discussions'
- elsif @pipeline&.blocked?
......
......@@ -141,6 +141,50 @@ describe 'Merge request', :feature, :js do
end
end
context 'view merge request with MWPS enabled but automatically merge fails' do
before do
merge_request.update(
merge_when_pipeline_succeeds: true,
merge_user: merge_request.author,
merge_error: 'Something went wrong'
)
visit namespace_project_merge_request_path(project.namespace, project, merge_request)
end
it 'shows information about the merge error' do
# Wait for the `ci_status` and `merge_check` requests
wait_for_ajax
page.within('.mr-widget-body') do
expect(page).to have_content('Something went wrong')
end
end
end
context 'view merge request with MWPS enabled but fast-forward merge is not possible' do
before do
project.update(merge_requests_ff_only_enabled: true)
merge_request.update(
merge_when_pipeline_succeeds: true,
merge_user: merge_request.author,
state: :can_be_merged
)
visit namespace_project_merge_request_path(project.namespace, project, merge_request)
end
it 'shows information about the merge error' do
# Wait for the `ci_status` and `merge_check` requests
wait_for_ajax
page.within('.mr-widget-body') do
expect(page).to have_content('Fast-forward merge is not possible')
end
end
end
context 'merge error' do
before do
allow_any_instance_of(Repository).to receive(:merge).and_return(false)
......
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