Commit 2ffdcc02 authored by mfluharty's avatar mfluharty

Rename receiving actions to begin with receive

parent cf1e2084
......@@ -4,8 +4,8 @@ import axios from '~/lib/utils/axios_utils';
import Poll from '~/lib/utils/poll';
import createFlash from '~/flash';
import { __, s__, n__, sprintf } from '~/locale';
import * as types from './mutation_types';
import _ from 'underscore';
import * as types from './mutation_types';
const API_MINIMUM_QUERY_LENGTH = 3;
......@@ -29,8 +29,8 @@ export const addProjectsToDashboard = ({ state, dispatch }) => {
.post(state.projectEndpoints.add, {
project_ids: state.selectedProjects.map(p => p.id),
})
.then(response => dispatch('requestAddProjectsToDashboardSuccess', response.data))
.catch(() => dispatch('requestAddProjectsToDashboardError'));
.then(response => dispatch('receiveAddProjectsToDashboardSuccess', response.data))
.catch(() => dispatch('receiveAddProjectsToDashboardError'));
};
export const toggleSelectedProject = ({ commit, state }, project) => {
......@@ -45,7 +45,7 @@ export const clearSearchResults = ({ commit }) => {
commit(types.CLEAR_SEARCH_RESULTS);
};
export const requestAddProjectsToDashboardSuccess = ({ dispatch, state }, data) => {
export const receiveAddProjectsToDashboardSuccess = ({ dispatch, state }, data) => {
const { added, invalid } = data;
if (invalid.length) {
......@@ -80,7 +80,7 @@ export const requestAddProjectsToDashboardSuccess = ({ dispatch, state }, data)
}
};
export const requestAddProjectsToDashboardError = ({ state }) => {
export const receiveAddProjectsToDashboardError = ({ state }) => {
createFlash(
sprintf(__('Something went wrong, unable to add %{project} to dashboard'), {
project: n__('project', 'projects', state.selectedProjects.length),
......@@ -131,15 +131,15 @@ export const receiveProjectsError = ({ commit }) => {
export const removeProject = ({ dispatch }, removePath) => {
axios
.delete(removePath)
.then(() => dispatch('requestRemoveProjectSuccess'))
.catch(() => dispatch('requestRemoveProjectError'));
.then(() => dispatch('receiveRemoveProjectSuccess'))
.catch(() => dispatch('receiveRemoveProjectError'));
};
export const requestRemoveProjectSuccess = ({ dispatch }) => {
dispatch('forceProjectsRequest');
export const receiveRemoveProjectSuccess = ({ dispatch }) => {
dispatch('fetchProjects');
};
export const requestRemoveProjectError = () => {
export const receiveRemoveProjectError = () => {
createFlash(__('Something went wrong, unable to remove project'));
};
......
......@@ -38,7 +38,7 @@ describe('actions', () => {
[],
[
{
type: 'requestAddProjectsToDashboardSuccess',
type: 'receiveAddProjectsToDashboardSuccess',
payload: mockResponse,
},
],
......@@ -54,7 +54,7 @@ describe('actions', () => {
null,
store.state,
[],
[{ type: 'requestAddProjectsToDashboardError' }],
[{ type: 'receiveAddProjectsToDashboardError' }],
done,
);
});
......@@ -96,10 +96,10 @@ describe('actions', () => {
});
});
describe('requestAddProjectsToDashboardSuccess', () => {
describe('receiveAddProjectsToDashboardSuccess', () => {
it('fetches projects when new projects are added to the dashboard', done => {
testAction(
actions.requestAddProjectsToDashboardSuccess,
actions.receiveAddProjectsToDashboardSuccess,
{
added: [1],
invalid: [],
......@@ -127,7 +127,7 @@ describe('actions', () => {
}
};
const addInvalidProjects = invalid =>
store.dispatch('requestAddProjectsToDashboardSuccess', {
store.dispatch('receiveAddProjectsToDashboardSuccess', {
added: [],
invalid,
duplicate: [],
......@@ -160,10 +160,10 @@ describe('actions', () => {
});
});
describe('requestAddProjectsToDashboardError', () => {
describe('receiveAddProjectsToDashboardError', () => {
it('shows error message', () => {
const spy = spyOnDependency(defaultActions, 'createFlash');
store.dispatch('requestAddProjectsToDashboardError');
store.dispatch('receiveAddProjectsToDashboardError');
expect(spy).toHaveBeenCalledWith(mockText.ADD_PROJECTS_ERROR);
});
......@@ -287,7 +287,7 @@ describe('actions', () => {
mockRemovePath,
null,
[],
[{ type: 'requestRemoveProjectSuccess' }],
[{ type: 'receiveRemoveProjectSuccess' }],
done,
);
});
......@@ -300,16 +300,16 @@ describe('actions', () => {
mockRemovePath,
null,
[],
[{ type: 'requestRemoveProjectError' }],
[{ type: 'receiveRemoveProjectError' }],
done,
);
});
});
describe('requestRemoveProjectSuccess', () => {
describe('receiveRemoveProjectSuccess', () => {
it('fetches operations dashboard projects', done => {
testAction(
actions.requestRemoveProjectSuccess,
actions.receiveRemoveProjectSuccess,
null,
null,
[],
......@@ -319,11 +319,11 @@ describe('actions', () => {
});
});
describe('requestRemoveProjectError', () => {
describe('receiveRemoveProjectError', () => {
it('displays project removal error', done => {
const spy = spyOnDependency(defaultActions, 'createFlash');
testAction(actions.requestRemoveProjectError, null, null, [], [], done);
testAction(actions.receiveRemoveProjectError, null, null, [], [], done);
expect(spy).toHaveBeenCalledWith(mockText.REMOVE_PROJECT_ERROR);
});
......
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