diff options
author | Phil Hughes <me@iamphill.com> | 2017-11-15 09:00:27 +0000 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2017-11-15 09:00:27 +0000 |
commit | 068f9df2bdf8b758360dbb81a449986b2636bc3b (patch) | |
tree | a60dd4c380535cacfec7f65c784a780c36598b54 | |
parent | 8ee3ea74f58e0b1e463aa8828efae0206904b380 (diff) | |
parent | 81862c2de1b26ab616b9eb27d0dd9b034483804d (diff) | |
download | gitlab-ce-068f9df2bdf8b758360dbb81a449986b2636bc3b.tar.gz |
Merge branch 'ce-backport-39009-fix-approvals-showing-up-in-empty-mr-widget' into 'master'
Remove approvals when in empty MR widget state -- CE backport
See merge request gitlab-org/gitlab-ce!15362
-rw-r--r-- | app/assets/javascripts/vue_merge_request_widget/mr_widget_options.js | 2 | ||||
-rw-r--r-- | spec/javascripts/vue_mr_widget/mr_widget_options_spec.js | 19 |
2 files changed, 11 insertions, 10 deletions
diff --git a/app/assets/javascripts/vue_merge_request_widget/mr_widget_options.js b/app/assets/javascripts/vue_merge_request_widget/mr_widget_options.js index f82938aa8a9..1274db2c4c8 100644 --- a/app/assets/javascripts/vue_merge_request_widget/mr_widget_options.js +++ b/app/assets/javascripts/vue_merge_request_widget/mr_widget_options.js @@ -61,7 +61,7 @@ export default { return this.mr.hasCI; }, shouldRenderRelatedLinks() { - return this.mr.relatedLinks; + return !!this.mr.relatedLinks; }, shouldRenderDeployments() { return this.mr.deployments.length; diff --git a/spec/javascripts/vue_mr_widget/mr_widget_options_spec.js b/spec/javascripts/vue_mr_widget/mr_widget_options_spec.js index 8832dd161c7..9e6d0aa472c 100644 --- a/spec/javascripts/vue_mr_widget/mr_widget_options_spec.js +++ b/spec/javascripts/vue_mr_widget/mr_widget_options_spec.js @@ -3,13 +3,7 @@ import mrWidgetOptions from '~/vue_merge_request_widget/mr_widget_options'; import eventHub from '~/vue_merge_request_widget/event_hub'; import notify from '~/lib/utils/notify'; import mockData from './mock_data'; - -const createComponent = () => { - delete mrWidgetOptions.el; // Prevent component mounting - gl.mrWidgetData = mockData; - const Component = Vue.extend(mrWidgetOptions); - return new Component(); -}; +import mountComponent from '../helpers/vue_mount_component_helper'; const returnPromise = data => new Promise((resolve) => { resolve({ @@ -22,9 +16,16 @@ const returnPromise = data => new Promise((resolve) => { describe('mrWidgetOptions', () => { let vm; + let MrWidgetOptions; beforeEach(() => { - vm = createComponent(); + // Prevent component mounting + delete mrWidgetOptions.el; + + MrWidgetOptions = Vue.extend(mrWidgetOptions); + vm = mountComponent(MrWidgetOptions, { + mrData: { ...mockData }, + }); }); describe('data', () => { @@ -77,7 +78,7 @@ describe('mrWidgetOptions', () => { }); it('should return true if there is relatedLinks in MR', () => { - vm.mr.relatedLinks = {}; + Vue.set(vm.mr, 'relatedLinks', {}); expect(vm.shouldRenderRelatedLinks).toBeTruthy(); }); }); |