Commit ca6e946f authored by Nathan Friend's avatar Nathan Friend

Only show message when MR is open

This commit fixes the bug that was causing the "target branch has
"advanced" error message to display after an MR was closed.
parent 951ffd9d
...@@ -119,7 +119,8 @@ export default { ...@@ -119,7 +119,8 @@ export default {
}, },
showTargetBranchAdvancedError() { showTargetBranchAdvancedError() {
return Boolean( return Boolean(
this.mr.pipeline && this.mr.isOpen &&
this.mr.pipeline &&
this.mr.pipeline.target_sha && this.mr.pipeline.target_sha &&
this.mr.pipeline.target_sha !== this.mr.targetBranchSha, this.mr.pipeline.target_sha !== this.mr.targetBranchSha,
); );
......
---
title: Only show the "target branch has advanced" message when the merge request is
open
merge_request: 27588
author:
type: fixed
...@@ -228,6 +228,7 @@ describe('mrWidgetOptions', () => { ...@@ -228,6 +228,7 @@ describe('mrWidgetOptions', () => {
describe('showTargetBranchAdvancedError', () => { describe('showTargetBranchAdvancedError', () => {
describe(`when the pipeline's target_sha property doesn't exist`, () => { describe(`when the pipeline's target_sha property doesn't exist`, () => {
beforeEach(done => { beforeEach(done => {
Vue.set(vm.mr, 'isOpen', true);
Vue.set(vm.mr.pipeline, 'target_sha', undefined); Vue.set(vm.mr.pipeline, 'target_sha', undefined);
Vue.set(vm.mr, 'targetBranchSha', 'abcd'); Vue.set(vm.mr, 'targetBranchSha', 'abcd');
vm.$nextTick(done); vm.$nextTick(done);
...@@ -240,6 +241,7 @@ describe('mrWidgetOptions', () => { ...@@ -240,6 +241,7 @@ describe('mrWidgetOptions', () => {
describe(`when the pipeline's target_sha matches the target branch's sha`, () => { describe(`when the pipeline's target_sha matches the target branch's sha`, () => {
beforeEach(done => { beforeEach(done => {
Vue.set(vm.mr, 'isOpen', true);
Vue.set(vm.mr.pipeline, 'target_sha', 'abcd'); Vue.set(vm.mr.pipeline, 'target_sha', 'abcd');
Vue.set(vm.mr, 'targetBranchSha', 'abcd'); Vue.set(vm.mr, 'targetBranchSha', 'abcd');
vm.$nextTick(done); vm.$nextTick(done);
...@@ -250,8 +252,22 @@ describe('mrWidgetOptions', () => { ...@@ -250,8 +252,22 @@ describe('mrWidgetOptions', () => {
}); });
}); });
describe(`when the merge request is not open`, () => {
beforeEach(done => {
Vue.set(vm.mr, 'isOpen', false);
Vue.set(vm.mr.pipeline, 'target_sha', 'abcd');
Vue.set(vm.mr, 'targetBranchSha', 'bcde');
vm.$nextTick(done);
});
it('should be false', () => {
expect(vm.showTargetBranchAdvancedError).toEqual(false);
});
});
describe(`when the pipeline's target_sha does not match the target branch's sha`, () => { describe(`when the pipeline's target_sha does not match the target branch's sha`, () => {
beforeEach(done => { beforeEach(done => {
Vue.set(vm.mr, 'isOpen', true);
Vue.set(vm.mr.pipeline, 'target_sha', 'abcd'); Vue.set(vm.mr.pipeline, 'target_sha', 'abcd');
Vue.set(vm.mr, 'targetBranchSha', 'bcde'); Vue.set(vm.mr, 'targetBranchSha', 'bcde');
vm.$nextTick(done); vm.$nextTick(done);
......
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