summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Zallmann <tzallmann@gitlab.com>2017-12-06 21:26:49 +0100
committerTim Zallmann <tzallmann@gitlab.com>2017-12-19 12:26:02 +0100
commit0923dd7446cf7e141d236de9ff762973a5defd90 (patch)
tree3ebe7632e9b698f49b88c846c7d6196954560c5f
parent5e70507c28be6ed794760b8c7d9eec257fea56ab (diff)
downloadgitlab-ce-0923dd7446cf7e141d236de9ff762973a5defd90.tar.gz
Fixed Actions Spec + Getters Spec Tests
-rw-r--r--app/assets/javascripts/ide/ide_router.js73
-rw-r--r--spec/javascripts/repo/stores/actions_spec.js2
-rw-r--r--spec/javascripts/repo/stores/getters_spec.js17
3 files changed, 51 insertions, 41 deletions
diff --git a/app/assets/javascripts/ide/ide_router.js b/app/assets/javascripts/ide/ide_router.js
index a3e833bf02d..b8303084fa6 100644
--- a/app/assets/javascripts/ide/ide_router.js
+++ b/app/assets/javascripts/ide/ide_router.js
@@ -56,42 +56,45 @@ const router = new VueRouter({
});
router.beforeEach((to, from, next) => {
- store.dispatch('getProjectData', {
- namespace: to.params.namespace,
- projectId: to.params.project,
- })
- .then(() => {
- const fullProjectId = `${to.params.namespace}/${to.params.project}`;
-
- if (to.params.branch) {
- store.dispatch('getBranchData', {
- projectId: fullProjectId,
- branchId: to.params.branch,
- });
-
- store.dispatch('getTreeData', {
- projectId: fullProjectId,
- branch: to.params.branch,
- endpoint: `/tree/${to.params.branch}`,
- })
- .then(() => {
- if (to.params[0]) {
- const treeEntry = getTreeEntry(store, `${to.params.namespace}/${to.params.project}/${to.params.branch}`, to.params[0]);
- if (treeEntry) {
- store.dispatch('handleTreeEntryAction', treeEntry);
+ if (to.params.namespace && to.params.project) {
+ store.dispatch('getProjectData', {
+ namespace: to.params.namespace,
+ projectId: to.params.project,
+ })
+ .then(() => {
+ const fullProjectId = `${to.params.namespace}/${to.params.project}`;
+
+ if (to.params.branch) {
+ store.dispatch('getBranchData', {
+ projectId: fullProjectId,
+ branchId: to.params.branch,
+ });
+
+ store.dispatch('getTreeData', {
+ projectId: fullProjectId,
+ branch: to.params.branch,
+ endpoint: `/tree/${to.params.branch}`,
+ })
+ .then(() => {
+ if (to.params[0]) {
+ const treeEntry = getTreeEntry(store, `${to.params.namespace}/${to.params.project}/${to.params.branch}`, to.params[0]);
+ if (treeEntry) {
+ store.dispatch('handleTreeEntryAction', treeEntry);
+ }
}
- }
- })
- .catch((e) => {
- flash('Error while loading the branch files. Please try again.');
- throw e;
- });
- }
- })
- .catch((e) => {
- flash('Error while loading the project data. Please try again.');
- throw e;
- });
+ })
+ .catch((e) => {
+ flash('Error while loading the branch files. Please try again.');
+ throw e;
+ });
+ }
+ })
+ .catch((e) => {
+ flash('Error while loading the project data. Please try again.');
+ throw e;
+ });
+ }
+
next();
});
diff --git a/spec/javascripts/repo/stores/actions_spec.js b/spec/javascripts/repo/stores/actions_spec.js
index a826053f0a8..0cbdbd0c7a6 100644
--- a/spec/javascripts/repo/stores/actions_spec.js
+++ b/spec/javascripts/repo/stores/actions_spec.js
@@ -4,7 +4,7 @@ import store from '~/ide/stores';
import service from '~/ide/services';
import { resetStore, file } from '../helpers';
-fdescribe('Multi-file store actions', () => {
+describe('Multi-file store actions', () => {
afterEach(() => {
resetStore(store);
});
diff --git a/spec/javascripts/repo/stores/getters_spec.js b/spec/javascripts/repo/stores/getters_spec.js
index 895a122c240..f0a55f1ee8d 100644
--- a/spec/javascripts/repo/stores/getters_spec.js
+++ b/spec/javascripts/repo/stores/getters_spec.js
@@ -11,15 +11,22 @@ describe('Multi-file store getters', () => {
describe('treeList', () => {
it('returns flat tree list', () => {
- localState.tree.push(file('1'));
- localState.tree[0].tree.push(file('2'));
- localState.tree[0].tree[0].tree.push(file('3'));
+ localState.trees = [];
+ localState.trees['abcproject/mybranch'] = {
+ tree: [],
+ };
+ const baseTree = localState.trees['abcproject/mybranch'].tree;
+ baseTree.push(file('1'));
+ baseTree[0].tree.push(file('2'));
+ baseTree[0].tree[0].tree.push(file('3'));
+
+ console.log('B : ', baseTree);
const treeList = getters.treeList(localState);
expect(treeList.length).toBe(3);
- expect(treeList[1].name).toBe(localState.tree[0].tree[0].name);
- expect(treeList[2].name).toBe(localState.tree[0].tree[0].tree[0].name);
+ expect(treeList[1].name).toBe(baseTree[0].tree[0].name);
+ expect(treeList[2].name).toBe(baseTree[0].tree[0].tree[0].name);
});
});