diff options
Diffstat (limited to 'spec/javascripts/ide/stores')
-rw-r--r-- | spec/javascripts/ide/stores/actions/merge_request_spec.js | 18 | ||||
-rw-r--r-- | spec/javascripts/ide/stores/modules/commit/actions_spec.js | 5 |
2 files changed, 21 insertions, 2 deletions
diff --git a/spec/javascripts/ide/stores/actions/merge_request_spec.js b/spec/javascripts/ide/stores/actions/merge_request_spec.js index 498e5142f0c..4917984cd42 100644 --- a/spec/javascripts/ide/stores/actions/merge_request_spec.js +++ b/spec/javascripts/ide/stores/actions/merge_request_spec.js @@ -8,7 +8,7 @@ import actions, { openMergeRequest, } from '~/ide/stores/actions/merge_request'; import service from '~/ide/services'; -import { activityBarViews } from '~/ide/constants'; +import { activityBarViews, PERMISSION_READ_MR } from '~/ide/constants'; import { resetStore } from '../../helpers'; const TEST_PROJECT = 'abcproject'; @@ -23,6 +23,9 @@ describe('IDE store merge request actions', () => { store.state.projects[TEST_PROJECT] = { id: TEST_PROJECT_ID, mergeRequests: {}, + userPermissions: { + [PERMISSION_READ_MR]: true, + }, }; }); @@ -79,6 +82,19 @@ describe('IDE store merge request actions', () => { }) .catch(done.fail); }); + + it('does nothing if user cannot read MRs', done => { + store.state.projects[TEST_PROJECT].userPermissions[PERMISSION_READ_MR] = false; + + store + .dispatch('getMergeRequestsForBranch', { projectId: TEST_PROJECT, branchId: 'bar' }) + .then(() => { + expect(service.getProjectMergeRequests).not.toHaveBeenCalled(); + expect(store.state.currentMergeRequestId).toBe(''); + }) + .then(done) + .catch(done.fail); + }); }); describe('no merge requests for branch available case', () => { diff --git a/spec/javascripts/ide/stores/modules/commit/actions_spec.js b/spec/javascripts/ide/stores/modules/commit/actions_spec.js index 056822bcfe5..fb8cb300209 100644 --- a/spec/javascripts/ide/stores/modules/commit/actions_spec.js +++ b/spec/javascripts/ide/stores/modules/commit/actions_spec.js @@ -7,7 +7,7 @@ import eventHub from '~/ide/eventhub'; import consts from '~/ide/stores/modules/commit/constants'; import * as mutationTypes from '~/ide/stores/modules/commit/mutation_types'; import * as actions from '~/ide/stores/modules/commit/actions'; -import { commitActionTypes } from '~/ide/constants'; +import { commitActionTypes, PERMISSION_CREATE_MR } from '~/ide/constants'; import testAction from '../../../../helpers/vuex_action_helper'; const TEST_COMMIT_SHA = '123456789'; @@ -313,6 +313,9 @@ describe('IDE commit module actions', () => { }, }, }, + userPermissions: { + [PERMISSION_CREATE_MR]: true, + }, }, }, }); |