Commit 9eb1bf9c authored by peterhegman's avatar peterhegman

Switch to using `gon.current_user_id`

Instead of parsing from `data-current-user-id`
parent b88c1959
......@@ -11,13 +11,13 @@ export default el => {
Vue.use(Vuex);
const { members, groupId, currentUserId } = el.dataset;
const { members, groupId } = el.dataset;
const store = new Vuex.Store({
...membersModule({
members: convertObjectPropsToCamelCase(JSON.parse(members), { deep: true }),
sourceId: parseInt(groupId, 10),
currentUserId: currentUserId ? parseInt(currentUserId, 10) : null,
currentUserId: gon.current_user_id || null,
}),
});
......
......@@ -4,7 +4,7 @@
- show_access_requests = can_manage_members && @requesters.exists?
- invited_active = params[:search_invited].present? || params[:invited_members_page].present?
- vue_members_list_enabled = Feature.enabled?(:vue_group_members_list, @group)
- data_attributes = { group_id: @group.id, current_user_id: current_user&.id }
- data_attributes = { group_id: @group.id }
- form_item_label_css_class = 'label-bold gl-mr-2 gl-mb-0 gl-py-2 align-self-md-center'
......
......@@ -16,9 +16,10 @@ describe('initGroupMembersApp', () => {
beforeEach(() => {
el = document.createElement('div');
el.setAttribute('data-members', membersJsonString);
el.setAttribute('data-current-user-id', '123');
el.setAttribute('data-group-id', '234');
window.gon = { current_user_id: 123 };
document.body.appendChild(el);
});
......@@ -36,15 +37,15 @@ describe('initGroupMembersApp', () => {
expect(wrapper.find(GroupMembersApp).exists()).toBe(true);
});
it('parses and sets `currentUserId` in Vuex store', () => {
it('sets `currentUserId` in Vuex store', () => {
setup();
expect(vm.$store.state.currentUserId).toBe(123);
});
describe('when `data-current-user-id` is not set (user is not logged in)', () => {
describe('when `gon.current_user_id` is not set (user is not logged in)', () => {
it('sets `currentUserId` as `null` in Vuex store', () => {
el.removeAttribute('data-current-user-id');
window.gon = {};
setup();
expect(vm.$store.state.currentUserId).toBeNull();
......
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