From c24b70682448f23d7eb01853026cfe6abdf86190 Mon Sep 17 00:00:00 2001 From: Alfredo Sumaran Date: Thu, 8 Jun 2017 03:45:18 -0500 Subject: Add tests when user has no direct acces to a group --- app/assets/javascripts/groups/index.js | 4 ++-- spec/javascripts/groups/group_item_spec.js | 31 ++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/groups/index.js b/app/assets/javascripts/groups/index.js index 5b7018153bf..ff601db2aa6 100644 --- a/app/assets/javascripts/groups/index.js +++ b/app/assets/javascripts/groups/index.js @@ -94,12 +94,12 @@ document.addEventListener('DOMContentLoaded', () => { this.isLoading = false; $.scrollTo(0); - const currentPath = gl.utils.mergeUrlParams({ page: page }, window.location.href); + const currentPath = gl.utils.mergeUrlParams({ page }, window.location.href); window.history.replaceState({ page: currentPath, }, document.title, currentPath); - this.updateGroups(response.json()); + this.updateGroups(response.json()); this.updatePagination(response.headers); }) .catch(this.handleErrorResponse); diff --git a/spec/javascripts/groups/group_item_spec.js b/spec/javascripts/groups/group_item_spec.js index 73ea86e6756..25e10552d95 100644 --- a/spec/javascripts/groups/group_item_spec.js +++ b/spec/javascripts/groups/group_item_spec.js @@ -63,9 +63,40 @@ describe('Groups Component', () => { }); }); + afterEach(() => { + component.$destroy(); + }); + it('should render group item correctly', () => { expect(component.$el.querySelector('.description').textContent).toBe(''); expect(component.$el.classList.contains('.no-description')).toBe(false); }); }); + + describe('user has not access to group', () => { + beforeEach((done) => { + GroupItemComponent = Vue.extend(groupItemComponent); + store = new GroupsStore(); + group1.permissions.human_group_access = null; + group = store.decorateGroup(group1); + + component = new GroupItemComponent({ + propsData: { + group, + }, + }).$mount(); + + Vue.nextTick(() => { + done(); + }); + }); + + afterEach(() => { + component.$destroy(); + }); + + it('should not display access type', () => { + expect(component.$el.querySelector('.access-type')).toBeNull(); + }); + }); }); -- cgit v1.2.1