Commit e563e820 authored by Clement Ho's avatar Clement Ho

Merge branch '5143-fix-epic-create' into 'master'

Fix Epics not getting created in a Group with existing Epics

Closes #5143

See merge request gitlab-org/gitlab-ee!4865
parents 71282101 70b3d3a7
...@@ -40,8 +40,7 @@ ...@@ -40,8 +40,7 @@
createEpic() { createEpic() {
this.creating = true; this.creating = true;
this.service.createEpic(this.title) this.service.createEpic(this.title)
.then(res => res.json()) .then(({ data }) => {
.then((data) => {
visitUrl(data.web_url); visitUrl(data.web_url);
}) })
.catch(() => { .catch(() => {
......
import Vue from 'vue'; import axios from '~/lib/utils/axios_utils';
import VueResource from 'vue-resource';
Vue.use(VueResource);
export default class NewEpicService { export default class NewEpicService {
constructor(endpoint) { constructor(endpoint) {
this.endpoint = endpoint; this.endpoint = endpoint;
this.resource = Vue.resource(this.endpoint, {});
} }
createEpic(title) { createEpic(title) {
return this.resource.save({ return axios.post(this.endpoint, {
title, title,
}); });
} }
......
---
title: Fix Epics not getting created in a Group with existing Epics
merge_request: 4865
author:
type: fixed
import Vue from 'vue'; import Vue from 'vue';
import _ from 'underscore'; import MockAdapter from 'axios-mock-adapter';
import axios from '~/lib/utils/axios_utils';
import newEpic from 'ee/epics/new_epic/components/new_epic.vue'; import newEpic from 'ee/epics/new_epic/components/new_epic.vue';
import * as urlUtility from '~/lib/utils/url_utility'; import * as urlUtility from '~/lib/utils/url_utility';
import mountComponent from 'spec/helpers/vue_mount_component_helper'; import mountComponent from 'spec/helpers/vue_mount_component_helper';
describe('newEpic', () => { describe('newEpic', () => {
let vm; let vm;
let mock;
const interceptor = (request, next) => {
next(request.respondWith(JSON.stringify({
web_url: gl.TEST_HOST,
}), {
status: 200,
}));
};
beforeEach(() => { beforeEach(() => {
Vue.http.interceptors.push(interceptor);
const NewEpic = Vue.extend(newEpic); const NewEpic = Vue.extend(newEpic);
mock = new MockAdapter(axios);
mock.onPost(gl.TEST_HOST).reply(200, { web_url: gl.TEST_HOST });
vm = mountComponent(NewEpic, { vm = mountComponent(NewEpic, {
endpoint: gl.TEST_HOST, endpoint: gl.TEST_HOST,
}); });
}); });
afterEach(() => { afterEach(() => {
Vue.http.interceptors = _.without(Vue.http.interceptors, interceptor); mock.restore();
vm.$destroy();
}); });
describe('alignRight', () => { describe('alignRight', () => {
......
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