Commit 2475019b authored by Phil Hughes's avatar Phil Hughes

Merge branch '42814-fix-remove-source-branch-when-mwps' into 'master'

Fix "Remove source branch" button in MR widget during MWPS state

Closes #42814 and #4281

See merge request gitlab-org/gitlab-ce!17192
parents bd26e012 aba1c07a
...@@ -63,7 +63,7 @@ ...@@ -63,7 +63,7 @@
}; };
this.isRemovingSourceBranch = true; this.isRemovingSourceBranch = true;
this.service.mergeResource.save(options) this.service.merge(options)
.then(res => res.data) .then(res => res.data)
.then((data) => { .then((data) => {
if (data.status === 'merge_when_pipeline_succeeds') { if (data.status === 'merge_when_pipeline_succeeds') {
......
---
title: Fix "Remove source branch" button in Merge request widget during merge when pipeline
succeeds state
merge_request: 17192
author:
type: fixed
...@@ -125,6 +125,12 @@ describe 'Merge request > User merges when pipeline succeeds', :js do ...@@ -125,6 +125,12 @@ describe 'Merge request > User merges when pipeline succeeds', :js do
expect(page).to have_content "canceled the automatic merge" expect(page).to have_content "canceled the automatic merge"
end end
it 'allows to remove source branch' do
click_link "Remove source branch"
expect(page).to have_content "The source branch will be removed"
end
context 'when pipeline succeeds' do context 'when pipeline succeeds' do
before do before do
build.success build.success
......
import Vue from 'vue'; import Vue from 'vue';
import mwpsComponent from '~/vue_merge_request_widget/components/states/mr_widget_merge_when_pipeline_succeeds.vue'; import mwpsComponent from '~/vue_merge_request_widget/components/states/mr_widget_merge_when_pipeline_succeeds.vue';
import MRWidgetService from '~/vue_merge_request_widget/services/mr_widget_service';
import eventHub from '~/vue_merge_request_widget/event_hub'; import eventHub from '~/vue_merge_request_widget/event_hub';
import mountComponent from 'spec/helpers/vue_mount_component_helper'; import mountComponent from 'spec/helpers/vue_mount_component_helper';
...@@ -25,12 +26,7 @@ describe('MRWidgetMergeWhenPipelineSucceeds', () => { ...@@ -25,12 +26,7 @@ describe('MRWidgetMergeWhenPipelineSucceeds', () => {
targetBranchPath, targetBranchPath,
targetBranch, targetBranch,
}, },
service: { service: new MRWidgetService({}),
cancelAutomaticMerge() {},
mergeResource: {
save() {},
},
},
}); });
}); });
...@@ -90,18 +86,16 @@ describe('MRWidgetMergeWhenPipelineSucceeds', () => { ...@@ -90,18 +86,16 @@ describe('MRWidgetMergeWhenPipelineSucceeds', () => {
describe('removeSourceBranch', () => { describe('removeSourceBranch', () => {
it('should set flag and call service then request main component to update the widget', (done) => { it('should set flag and call service then request main component to update the widget', (done) => {
spyOn(vm.service.mergeResource, 'save').and.returnValue(new Promise((resolve) => { spyOn(vm.service, 'merge').and.returnValue(Promise.resolve({
resolve({
data: { data: {
status: 'merge_when_pipeline_succeeds', status: 'merge_when_pipeline_succeeds',
}, },
});
})); }));
vm.removeSourceBranch(); vm.removeSourceBranch();
setTimeout(() => { setTimeout(() => {
expect(eventHub.$emit).toHaveBeenCalledWith('MRWidgetUpdateRequested'); expect(eventHub.$emit).toHaveBeenCalledWith('MRWidgetUpdateRequested');
expect(vm.service.mergeResource.save).toHaveBeenCalledWith({ expect(vm.service.merge).toHaveBeenCalledWith({
sha, sha,
merge_when_pipeline_succeeds: true, merge_when_pipeline_succeeds: true,
should_remove_source_branch: true, should_remove_source_branch: true,
......
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