Commit 6c70491d authored by mfluharty's avatar mfluharty

Use not found constant in more places

Use STATUS_NOT_FOUND in code quality report actions
and related component specs and store specs
parent 189b5e69
import pollUntilComplete from '~/lib/utils/poll_until_complete'; import pollUntilComplete from '~/lib/utils/poll_until_complete';
import { STATUS_NOT_FOUND } from '../../constants';
import * as types from './mutation_types'; import * as types from './mutation_types';
import { parseCodeclimateMetrics } from './utils/codequality_parser'; import { parseCodeclimateMetrics } from './utils/codequality_parser';
...@@ -9,7 +10,7 @@ export const fetchReports = ({ state, dispatch, commit }) => { ...@@ -9,7 +10,7 @@ export const fetchReports = ({ state, dispatch, commit }) => {
return pollUntilComplete(state.reportsPath) return pollUntilComplete(state.reportsPath)
.then(({ data }) => { .then(({ data }) => {
if (data.status === 'not_found') { if (data.status === STATUS_NOT_FOUND) {
return dispatch('receiveReportsError', data); return dispatch('receiveReportsError', data);
} }
return dispatch('receiveReportsSuccess', { return dispatch('receiveReportsSuccess', {
......
...@@ -3,6 +3,7 @@ import Vuex from 'vuex'; ...@@ -3,6 +3,7 @@ import Vuex from 'vuex';
import CodequalityIssueBody from '~/reports/codequality_report/components/codequality_issue_body.vue'; import CodequalityIssueBody from '~/reports/codequality_report/components/codequality_issue_body.vue';
import GroupedCodequalityReportsApp from '~/reports/codequality_report/grouped_codequality_reports_app.vue'; import GroupedCodequalityReportsApp from '~/reports/codequality_report/grouped_codequality_reports_app.vue';
import { getStoreConfig } from '~/reports/codequality_report/store'; import { getStoreConfig } from '~/reports/codequality_report/store';
import { STATUS_NOT_FOUND } from '~/reports/constants';
import { parsedReportIssues } from './mock_data'; import { parsedReportIssues } from './mock_data';
const localVue = createLocalVue(); const localVue = createLocalVue();
...@@ -140,7 +141,7 @@ describe('Grouped code quality reports app', () => { ...@@ -140,7 +141,7 @@ describe('Grouped code quality reports app', () => {
describe('when base report was not found', () => { describe('when base report was not found', () => {
beforeEach(() => { beforeEach(() => {
mockStore.state.status = 'not_found'; mockStore.state.status = STATUS_NOT_FOUND;
}); });
it('renders a help icon with more information', () => { it('renders a help icon with more information', () => {
......
...@@ -5,6 +5,7 @@ import axios from '~/lib/utils/axios_utils'; ...@@ -5,6 +5,7 @@ import axios from '~/lib/utils/axios_utils';
import createStore from '~/reports/codequality_report/store'; import createStore from '~/reports/codequality_report/store';
import * as actions from '~/reports/codequality_report/store/actions'; import * as actions from '~/reports/codequality_report/store/actions';
import * as types from '~/reports/codequality_report/store/mutation_types'; import * as types from '~/reports/codequality_report/store/mutation_types';
import { STATUS_NOT_FOUND } from '~/reports/constants';
import { reportIssues, parsedReportIssues } from '../mock_data'; import { reportIssues, parsedReportIssues } from '../mock_data';
const pollInterval = 123; const pollInterval = 123;
...@@ -91,7 +92,7 @@ describe('Codequality Reports actions', () => { ...@@ -91,7 +92,7 @@ describe('Codequality Reports actions', () => {
describe('when base report is not found', () => { describe('when base report is not found', () => {
it('commits REQUEST_REPORTS and dispatches receiveReportsError', (done) => { it('commits REQUEST_REPORTS and dispatches receiveReportsError', (done) => {
const data = { status: 'not_found' }; const data = { status: STATUS_NOT_FOUND };
mock.onGet(`${TEST_HOST}/codequality_reports.json`).reply(200, data); mock.onGet(`${TEST_HOST}/codequality_reports.json`).reply(200, data);
testAction( testAction(
......
import createStore from '~/reports/codequality_report/store'; import createStore from '~/reports/codequality_report/store';
import * as getters from '~/reports/codequality_report/store/getters'; import * as getters from '~/reports/codequality_report/store/getters';
import { LOADING, ERROR, SUCCESS } from '~/reports/constants'; import { LOADING, ERROR, SUCCESS, STATUS_NOT_FOUND } from '~/reports/constants';
describe('Codequality reports store getters', () => { describe('Codequality reports store getters', () => {
let localState; let localState;
...@@ -78,7 +78,7 @@ describe('Codequality reports store getters', () => { ...@@ -78,7 +78,7 @@ describe('Codequality reports store getters', () => {
describe('codequalityPopover', () => { describe('codequalityPopover', () => {
describe('when base report is not available', () => { describe('when base report is not available', () => {
it('returns a popover with a documentation link', () => { it('returns a popover with a documentation link', () => {
localState.status = 'not_found'; localState.status = STATUS_NOT_FOUND;
localState.helpPath = 'codequality_help.html'; localState.helpPath = 'codequality_help.html';
expect(getters.codequalityPopover(localState).title).toEqual( expect(getters.codequalityPopover(localState).title).toEqual(
......
import createStore from '~/reports/codequality_report/store'; import createStore from '~/reports/codequality_report/store';
import mutations from '~/reports/codequality_report/store/mutations'; import mutations from '~/reports/codequality_report/store/mutations';
import { STATUS_NOT_FOUND } from '~/reports/constants';
describe('Codequality Reports mutations', () => { describe('Codequality Reports mutations', () => {
let localState; let localState;
...@@ -82,7 +83,7 @@ describe('Codequality Reports mutations', () => { ...@@ -82,7 +83,7 @@ describe('Codequality Reports mutations', () => {
}); });
it('sets status based on error object', () => { it('sets status based on error object', () => {
const error = { status: 'not_found' }; const error = { status: STATUS_NOT_FOUND };
mutations.RECEIVE_REPORTS_ERROR(localState, error); mutations.RECEIVE_REPORTS_ERROR(localState, error);
expect(localState.status).toEqual(error.status); expect(localState.status).toEqual(error.status);
......
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