Commit e369323d authored by Clement Ho's avatar Clement Ho

Fix filtered search user autocomplete for gitlab instances that are hosted on a subdirectory

parent 96baf2bc
......@@ -8,7 +8,7 @@ require('./filtered_search_dropdown');
super(droplab, dropdown, input, filter);
this.config = {
droplabAjaxFilter: {
endpoint: '/autocomplete/users.json',
endpoint: `${gon.relative_url_root || ''}/autocomplete/users.json`,
searchKey: 'search',
params: {
per_page: 20,
......
---
title: Fix filtered search user autocomplete for gitlab instances that are hosted
on a subdirectory
merge_request: 8891
author:
......@@ -36,5 +36,40 @@ require('~/filtered_search/dropdown_user');
expect(dropdownUser.getSearchInput()).toBe('larry boy');
});
});
describe('config droplabAjaxFilter\'s endpoint', () => {
beforeEach(() => {
spyOn(gl.FilteredSearchDropdown.prototype, 'constructor').and.callFake(() => {});
spyOn(gl.DropdownUser.prototype, 'getProjectId').and.callFake(() => {});
});
it('should return endpoint', () => {
window.gon = {
relative_url_root: '',
};
const dropdown = new gl.DropdownUser();
expect(dropdown.config.droplabAjaxFilter.endpoint).toBe('/autocomplete/users.json');
});
it('should return endpoint when relative_url_root is undefined', () => {
const dropdown = new gl.DropdownUser();
expect(dropdown.config.droplabAjaxFilter.endpoint).toBe('/autocomplete/users.json');
});
it('should return endpoint with relative url when available', () => {
window.gon = {
relative_url_root: '/gitlab_directory',
};
const dropdown = new gl.DropdownUser();
expect(dropdown.config.droplabAjaxFilter.endpoint).toBe('/gitlab_directory/autocomplete/users.json');
});
afterEach(() => {
window.gon = {};
});
});
});
})();
......@@ -9,19 +9,20 @@ require('~/project_select');
require('~/project');
(function() {
window.gon || (window.gon = {});
window.gon.api_version = 'v3';
describe('Project Title', function() {
preloadFixtures('static/project_title.html.raw');
loadJSONFixtures('projects.json');
beforeEach(function() {
loadFixtures('static/project_title.html.raw');
window.gon = {};
window.gon.api_version = 'v3';
return this.project = new Project();
});
return describe('project list', function() {
describe('project list', function() {
var fakeAjaxResponse = function fakeAjaxResponse(req) {
var d;
expect(req.url).toBe('/api/v3/projects.json?simple=true');
......@@ -48,5 +49,9 @@ require('~/project');
return expect($('.header-content').hasClass('open')).toBe(false);
});
});
afterEach(() => {
window.gon = {};
});
});
}).call(this);
......@@ -14,11 +14,6 @@ require('vendor/fuzzaldrin-plus');
userId = 1;
window.gon || (window.gon = {});
window.gon.current_user_id = userId;
window.gon.current_username = userName;
dashboardIssuesPath = '/dashboard/issues';
dashboardMRsPath = '/dashboard/merge_requests';
......@@ -117,6 +112,16 @@ require('vendor/fuzzaldrin-plus');
widget = new gl.SearchAutocomplete;
// Prevent turbolinks from triggering within gl_dropdown
spyOn(window.gl.utils, 'visitUrl').and.returnValue(true);
window.gon = {};
window.gon.current_user_id = userId;
window.gon.current_username = userName;
return widget = new gl.SearchAutocomplete;
});
afterEach(function() {
window.gon = {};
});
it('should show Dashboard specific dropdown menu', function() {
var list;
......
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