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