未验证 提交 6243c04e 编写于 作者: F Fatih Acet

Fix failing specs and lint errors.

上级 10649c49
......@@ -214,10 +214,16 @@ export default {
},
updateStoreState() {
this.service.getData()
this.service
.getData()
.then(res => res.data)
.then(data => {
this.store.updateState(data);
})
.catch(() => {
const errMsg = `Error updating ${this.issuableType}`;
window.Flash(errMsg);
});
},
......
......@@ -39,6 +39,7 @@ export default {
lockVersion: {
type: Number,
required: false,
default: 0,
},
},
data() {
......@@ -89,8 +90,10 @@ export default {
}
},
taskListUpdateError({ errors, data }) {
createFlash('Someone edited this issue at the same time you did and we updated the issue description.');
taskListUpdateError() {
createFlash(
'Someone edited this issue at the same time you did and we updated the issue description.',
);
this.$emit('taskListUpdateFailed');
},
......
......@@ -10,15 +10,17 @@ export default class TaskList {
this.fieldName = options.fieldName;
this.lockVersion = options.lockVersion;
this.onSuccess = options.onSuccess || (() => {});
this.onError = options.onError || function showFlash(e) {
let errorMessages = '';
this.onError =
options.onError ||
function showFlash(e) {
let errorMessages = '';
if (e.response.data && typeof e.response.data === 'object') {
errorMessages = e.response.data.errors.join(' ');
}
if (e.response.data && typeof e.response.data === 'object') {
errorMessages = e.response.data.errors.join(' ');
}
return new Flash(errorMessages || 'Update failed', 'alert');
};
return new Flash(errorMessages || 'Update failed', 'alert');
};
this.init();
}
......@@ -56,8 +58,8 @@ export default class TaskList {
[this.fieldName]: $target.val(),
lock_version: this.lockVersion,
update_task: {
index: index,
checked: checked,
index,
checked,
line_number: lineNumber,
line_source: lineSource,
},
......
......@@ -123,7 +123,10 @@ describe('Description component', () => {
fieldName: 'description',
selector: '.detail-page-description',
onSuccess: jasmine.any(Function),
onError: jasmine.any(Function),
lockVersion: 0,
});
done();
});
});
......
......@@ -41,15 +41,28 @@ describe('MergeRequest', function() {
});
it('submits an ajax request on tasklist:changed', done => {
$('.js-task-list-field').trigger('tasklist:changed');
const lineNumber = 8;
const lineSource = '- [ ] item 8';
const index = 3;
const checked = true;
$('.js-task-list-field').trigger({
type: 'tasklist:changed',
detail: { lineNumber, lineSource, index, checked },
});
setTimeout(() => {
expect(axios.patch).toHaveBeenCalledWith(
`${gl.TEST_HOST}/frontend-fixtures/merge-requests-project/merge_requests/1.json`,
{
merge_request: { description: '- [ ] Task List Item' },
merge_request: {
description: '- [ ] Task List Item',
lock_version: undefined,
update_task: { line_number: lineNumber, line_source: lineSource, index, checked },
},
},
);
done();
});
});
......
......@@ -89,10 +89,25 @@ describe('Notes', function() {
});
it('submits an ajax request on tasklist:changed', function(done) {
$('.js-task-list-container').trigger('tasklist:changed');
const lineNumber = 8;
const lineSource = '- [ ] item 8';
const index = 3;
const checked = true;
$('.js-task-list-container').trigger({
type: 'tasklist:changed',
detail: { lineNumber, lineSource, index, checked },
});
setTimeout(() => {
expect(axios.patch).toHaveBeenCalled();
expect(axios.patch).toHaveBeenCalledWith(undefined, {
note: {
note: '',
lock_version: undefined,
update_task: { index, checked, line_number: lineNumber, line_source: lineSource },
},
});
done();
});
});
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册