Remove deleteNote from notes service
This commit is contained in:
parent
426597590c
commit
49d5cc34ca
4 changed files with 15 additions and 15 deletions
|
@ -9,9 +9,6 @@ export default {
|
||||||
const config = filter !== undefined ? { params: { notes_filter: filter } } : null;
|
const config = filter !== undefined ? { params: { notes_filter: filter } } : null;
|
||||||
return Vue.http.get(endpoint, config);
|
return Vue.http.get(endpoint, config);
|
||||||
},
|
},
|
||||||
deleteNote(endpoint) {
|
|
||||||
return Vue.http.delete(endpoint);
|
|
||||||
},
|
|
||||||
replyToDiscussion(endpoint, data) {
|
replyToDiscussion(endpoint, data) {
|
||||||
return Vue.http.post(endpoint, data, { emulateJSON: true });
|
return Vue.http.post(endpoint, data, { emulateJSON: true });
|
||||||
},
|
},
|
||||||
|
|
|
@ -62,7 +62,7 @@ export const updateDiscussion = ({ commit, state }, discussion) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
export const deleteNote = ({ commit, dispatch, state }, note) =>
|
export const deleteNote = ({ commit, dispatch, state }, note) =>
|
||||||
service.deleteNote(note.path).then(() => {
|
axios.delete(note.path).then(() => {
|
||||||
const discussion = state.discussions.find(({ id }) => id === note.discussion_id);
|
const discussion = state.discussions.find(({ id }) => id === note.discussion_id);
|
||||||
|
|
||||||
commit(types.DELETE_NOTE, note);
|
commit(types.DELETE_NOTE, note);
|
||||||
|
|
5
changelogs/unreleased/winh-notes-service-deleteNote.yml
Normal file
5
changelogs/unreleased/winh-notes-service-deleteNote.yml
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
title: Remove deleteNote from notes service
|
||||||
|
merge_request: 30537
|
||||||
|
author: Frank van Rest
|
||||||
|
type: other
|
|
@ -18,6 +18,8 @@ import {
|
||||||
noteableDataMock,
|
noteableDataMock,
|
||||||
individualNote,
|
individualNote,
|
||||||
} from '../mock_data';
|
} from '../mock_data';
|
||||||
|
import AxiosMockAdapter from 'axios-mock-adapter';
|
||||||
|
import axios from '~/lib/utils/axios_utils';
|
||||||
|
|
||||||
const TEST_ERROR_MESSAGE = 'Test error message';
|
const TEST_ERROR_MESSAGE = 'Test error message';
|
||||||
|
|
||||||
|
@ -335,28 +337,24 @@ describe('Actions Notes Store', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('deleteNote', () => {
|
describe('deleteNote', () => {
|
||||||
const interceptor = (request, next) => {
|
const endpoint = `${TEST_HOST}/note`;
|
||||||
next(
|
let axiosMock;
|
||||||
request.respondWith(JSON.stringify({}), {
|
|
||||||
status: 200,
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
Vue.http.interceptors.push(interceptor);
|
axiosMock = new AxiosMockAdapter(axios);
|
||||||
|
axiosMock.onDelete(endpoint).replyOnce(200, {});
|
||||||
|
|
||||||
$('body').attr('data-page', '');
|
$('body').attr('data-page', '');
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
Vue.http.interceptors = _.without(Vue.http.interceptors, interceptor);
|
axiosMock.restore();
|
||||||
|
|
||||||
$('body').attr('data-page', '');
|
$('body').attr('data-page', '');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('commits DELETE_NOTE and dispatches updateMergeRequestWidget', done => {
|
it('commits DELETE_NOTE and dispatches updateMergeRequestWidget', done => {
|
||||||
const note = { path: `${gl.TEST_HOST}`, id: 1 };
|
const note = { path: endpoint, id: 1 };
|
||||||
|
|
||||||
testAction(
|
testAction(
|
||||||
actions.deleteNote,
|
actions.deleteNote,
|
||||||
|
@ -381,7 +379,7 @@ describe('Actions Notes Store', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('dispatches removeDiscussionsFromDiff on merge request page', done => {
|
it('dispatches removeDiscussionsFromDiff on merge request page', done => {
|
||||||
const note = { path: `${gl.TEST_HOST}`, id: 1 };
|
const note = { path: endpoint, id: 1 };
|
||||||
|
|
||||||
$('body').attr('data-page', 'projects:merge_requests:show');
|
$('body').attr('data-page', 'projects:merge_requests:show');
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue