Commit 468f9168 authored by Fatih Acet's avatar Fatih Acet

MRWidget: Change order of if blocks to determine widget state properly.

parent 52527be4
...@@ -11,10 +11,6 @@ export default function deviseState(data) { ...@@ -11,10 +11,6 @@ export default function deviseState(data) {
return 'conflicts'; return 'conflicts';
} else if (data.work_in_progress) { } else if (data.work_in_progress) {
return 'workInProgress'; return 'workInProgress';
} else if (this.mergeWhenPipelineSucceeds) {
return this.mergeError ? 'autoMergeFailed' : 'mergeWhenPipelineSucceeds';
} else if (!this.canMerge) {
return 'notAllowedToMerge';
} else if (this.onlyAllowMergeIfPipelineSucceeds && this.isPipelineFailed) { } else if (this.onlyAllowMergeIfPipelineSucceeds && this.isPipelineFailed) {
return 'pipelineFailed'; return 'pipelineFailed';
} else if (this.hasMergeableDiscussionsState) { } else if (this.hasMergeableDiscussionsState) {
...@@ -23,6 +19,10 @@ export default function deviseState(data) { ...@@ -23,6 +19,10 @@ export default function deviseState(data) {
return 'pipelineBlocked'; return 'pipelineBlocked';
} else if (this.hasSHAChanged) { } else if (this.hasSHAChanged) {
return 'shaMismatch'; return 'shaMismatch';
} else if (this.mergeWhenPipelineSucceeds) {
return this.mergeError ? 'autoMergeFailed' : 'mergeWhenPipelineSucceeds';
} else if (!this.canMerge) {
return 'notAllowedToMerge';
} else if (this.canBeMerged) { } else if (this.canBeMerged) {
return 'readyToMerge'; return 'readyToMerge';
} }
......
...@@ -25,6 +25,12 @@ describe('getStateKey', () => { ...@@ -25,6 +25,12 @@ describe('getStateKey', () => {
context.canBeMerged = true; context.canBeMerged = true;
expect(bound()).toEqual('readyToMerge'); expect(bound()).toEqual('readyToMerge');
context.canMerge = false;
expect(bound()).toEqual('notAllowedToMerge');
context.mergeWhenPipelineSucceeds = true;
expect(bound()).toEqual('mergeWhenPipelineSucceeds');
context.hasSHAChanged = true; context.hasSHAChanged = true;
expect(bound()).toEqual('shaMismatch'); expect(bound()).toEqual('shaMismatch');
...@@ -38,12 +44,6 @@ describe('getStateKey', () => { ...@@ -38,12 +44,6 @@ describe('getStateKey', () => {
context.isPipelineFailed = true; context.isPipelineFailed = true;
expect(bound()).toEqual('pipelineFailed'); expect(bound()).toEqual('pipelineFailed');
context.canMerge = false;
expect(bound()).toEqual('notAllowedToMerge');
context.mergeWhenPipelineSucceeds = true;
expect(bound()).toEqual('mergeWhenPipelineSucceeds');
data.work_in_progress = true; data.work_in_progress = true;
expect(bound()).toEqual('workInProgress'); expect(bound()).toEqual('workInProgress');
......
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