Commit 109a57af authored by Kushal Pandya's avatar Kushal Pandya

Merge branch 'ph/331265/stopRequestsToEmojiEndpoint' into 'master'

Fixes emoji endpoint being called when user not signed in

See merge request gitlab-org/gitlab!62468
parents 89ea7630 fa8c83ea
......@@ -13,6 +13,8 @@ import {
export const setInitialData = ({ commit }, data) => commit(SET_INITIAL_DATA, data);
export const fetchAwards = async ({ commit, dispatch, state }, page = '1') => {
if (!window.gon?.current_user_id) return;
try {
const { data, headers } = await axios.get(state.path, { params: { per_page: 100, page } });
const normalizedHeaders = normalizeHeaders(headers);
......
......@@ -7,6 +7,10 @@ import axios from '~/lib/utils/axios_utils';
jest.mock('@sentry/browser');
describe('Awards app actions', () => {
afterEach(() => {
window.gon = {};
});
describe('setInitialData', () => {
it('commits SET_INITIAL_DATA', async () => {
await testAction(
......@@ -39,6 +43,8 @@ describe('Awards app actions', () => {
});
it('commits FETCH_AWARDS_SUCCESS', async () => {
window.gon = { current_user_id: 1 };
await testAction(
actions.fetchAwards,
'1',
......@@ -47,6 +53,10 @@ describe('Awards app actions', () => {
[{ type: 'fetchAwards', payload: '2' }],
);
});
it('does not commit FETCH_AWARDS_SUCCESS when user signed out', async () => {
await testAction(actions.fetchAwards, '1', { path: '/awards' }, [], []);
});
});
describe('error', () => {
......@@ -55,6 +65,8 @@ describe('Awards app actions', () => {
});
it('calls Sentry.captureException', async () => {
window.gon = { current_user_id: 1 };
await testAction(actions.fetchAwards, null, { path: '/awards' }, [], [], () => {
expect(Sentry.captureException).toHaveBeenCalled();
});
......
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