summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhil Hughes <me@iamphill.com>2018-02-01 09:14:53 +0000
committerPhil Hughes <me@iamphill.com>2018-02-01 09:14:53 +0000
commit4377b4795fedcb5145d76fab09ccd468ce3a2138 (patch)
tree2d23d392616747a5996c11a2a689bc49e6cec9b6
parent988747df49d9441f539c51efd6f808f77173c3e0 (diff)
downloadgitlab-ce-4377b4795fedcb5145d76fab09ccd468ce3a2138.tar.gz
remove useless ajaxPost method
-rw-r--r--app/assets/javascripts/lib/utils/common_utils.js3
-rw-r--r--app/assets/javascripts/notes.js11
-rw-r--r--spec/javascripts/lib/utils/common_utils_spec.js13
3 files changed, 6 insertions, 21 deletions
diff --git a/app/assets/javascripts/lib/utils/common_utils.js b/app/assets/javascripts/lib/utils/common_utils.js
index c27c4c6e621..5811d059e0b 100644
--- a/app/assets/javascripts/lib/utils/common_utils.js
+++ b/app/assets/javascripts/lib/utils/common_utils.js
@@ -35,8 +35,6 @@ export const ajaxGet = url => axios.get(url, {
$.globalEval(data);
});
-export const ajaxPost = (url, data) => axios.post(url, data);
-
export const rstrip = (val) => {
if (val) {
return val.replace(/\s+$/, '');
@@ -409,7 +407,6 @@ window.gl.utils = {
getGroupSlug,
isInIssuePage,
ajaxGet,
- ajaxPost,
rstrip,
updateTooltipTitle,
disableButtonIfEmptyField,
diff --git a/app/assets/javascripts/notes.js b/app/assets/javascripts/notes.js
index 2f37d40ebad..429d50f5463 100644
--- a/app/assets/javascripts/notes.js
+++ b/app/assets/javascripts/notes.js
@@ -17,13 +17,14 @@ import 'vendor/jquery.caret'; // required by jquery.atwho
import 'vendor/jquery.atwho';
import AjaxCache from '~/lib/utils/ajax_cache';
import { getLocationHash } from './lib/utils/url_utility';
+import axios from './lib/utils/axios_utils';
import Flash from './flash';
import CommentTypeToggle from './comment_type_toggle';
import GLForm from './gl_form';
import loadAwardsHandler from './awards_handler';
import Autosave from './autosave';
import TaskList from './task_list';
-import { ajaxPost, isInViewport, getPagePath, scrollToElement, isMetaKey } from './lib/utils/common_utils';
+import { isInViewport, getPagePath, scrollToElement, isMetaKey } from './lib/utils/common_utils';
import imageDiffHelper from './image_diff/helpers/index';
import { localTimeAgo } from './lib/utils/datetime_utility';
@@ -1404,7 +1405,7 @@ export default class Notes {
* 2) Identify comment type; a) Main thread b) Discussion thread c) Discussion resolve
* 3) Build temporary placeholder element (using `createPlaceholderNote`)
* 4) Show placeholder note on UI
- * 5) Perform network request to submit the note using `ajaxPost`
+ * 5) Perform network request to submit the note using `axios.post`
* a) If request is successfully completed
* 1. Remove placeholder element
* 2. Show submitted Note element
@@ -1486,7 +1487,7 @@ export default class Notes {
/* eslint-disable promise/catch-or-return */
// Make request to submit comment on server
- ajaxPost(formAction, formData)
+ axios.post(formAction, formData)
.then((res) => {
const note = res.data;
@@ -1601,7 +1602,7 @@ export default class Notes {
*
* 1) Get Form metadata
* 2) Update note element with new content
- * 3) Perform network request to submit the updated note using `ajaxPost`
+ * 3) Perform network request to submit the updated note using `axios.post`
* a) If request is successfully completed
* 1. Show submitted Note element
* b) If request failed
@@ -1632,7 +1633,7 @@ export default class Notes {
/* eslint-disable promise/catch-or-return */
// Make request to update comment on server
- ajaxPost(formAction, formData)
+ axios.post(formAction, formData)
.then(({ data }) => {
// Submission successful! render final note element
this.updateNote(data, $editingNote);
diff --git a/spec/javascripts/lib/utils/common_utils_spec.js b/spec/javascripts/lib/utils/common_utils_spec.js
index 864ee4995ea..80430011aed 100644
--- a/spec/javascripts/lib/utils/common_utils_spec.js
+++ b/spec/javascripts/lib/utils/common_utils_spec.js
@@ -459,19 +459,6 @@ describe('common_utils', () => {
});
});
- describe('ajaxPost', () => {
- it('should perform `$.ajax` call and do `POST` request', () => {
- const requestURL = '/some/random/api';
- const data = { keyname: 'value' };
- const ajaxSpy = spyOn(axios, 'post').and.callFake(() => {});
-
- commonUtils.ajaxPost(requestURL, data);
-
- expect(ajaxSpy.calls.allArgs()[0][0]).toEqual(requestURL);
- expect(ajaxSpy.calls.allArgs()[0][1]).toEqual(data);
- });
- });
-
describe('spriteIcon', () => {
let beforeGon;