Commit 8b4059d3 authored by Phil Hughes's avatar Phil Hughes

Updated ldap_groups to axios

parent 6def9128
......@@ -196,15 +196,17 @@ const Api = {
ldap_groups(query, provider, callback) {
const url = Api.buildUrl(this.ldapGroupsPath).replace(':provider', provider);
return Api.wrapAjaxCall({
url,
data: Object.assign({
return axios.get(url, {
params: {
search: query,
per_page: 20,
active: true,
}),
dataType: 'json',
}).then(groups => callback(groups));
},
}).then(({ data }) => {
callback(data);
return data;
});
},
buildUrl(url) {
......
......@@ -145,16 +145,16 @@ describe('Api', () => {
const expectedData = {
label: labelData,
};
spyOn(jQuery, 'ajax').and.callFake((request) => {
expect(request.url).toEqual(expectedUrl);
expect(request.dataType).toEqual('json');
expect(request.type).toEqual('POST');
expect(request.data).toEqual(expectedData);
return sendDummyResponse();
mock.onPost(expectedUrl).reply((config) => {
expect(config.data).toBe(JSON.stringify(expectedData));
return [200, {
name: 'test',
}];
});
Api.newLabel(namespace, null, labelData, (response) => {
expect(response).toBe(dummyResponse);
expect(response.name).toBe('test');
done();
});
});
......@@ -270,8 +270,11 @@ describe('Api', () => {
const query = 'query';
const provider = 'provider';
const callback = jasmine.createSpy();
const expectedUrl = `${dummyUrlRoot}/api/${dummyApiVersion}/ldap/${provider}/groups.json`;
spyOn(jQuery, 'ajax').and.callFake(() => $.Deferred().resolve());
mock.onGet(expectedUrl).reply(200, [{
name: 'test',
}]);
Api.ldap_groups(query, provider, callback)
.then((response) => {
......
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