BigW Consortium Gitlab

Unverified Commit 7e0831ba by Filipa Lacerda Committed by Rémy Coutable

Merge branch '27343-autocomplete-post-to-wrong-url-when-not-hosting-in-root' into 'master'

Fix filtered search user autocomplete for gitlab instances that are hosted on a subdirectory Closes #27343 See merge request !8891 Signed-off-by: 's avatarRémy Coutable <remy@rymai.me>
parent 208adc0d
......@@ -8,7 +8,7 @@
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 @@
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 = {};
});
});
});
})();
......@@ -11,17 +11,18 @@
/*= require project */
(function() {
window.gon || (window.gon = {});
window.gon.api_version = 'v3';
describe('Project Title', function() {
preloadFixtures('static/project_title.html.raw');
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,6 +49,10 @@
return expect($('.header-content').hasClass('open')).toBe(false);
});
});
afterEach(() => {
window.gon = {};
});
});
}).call(this);
......@@ -17,11 +17,6 @@
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,8 +112,20 @@
preloadFixtures('static/search_autocomplete.html.raw');
beforeEach(function() {
loadFixtures('static/search_autocomplete.html.raw');
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;
addBodyAttributes();
......
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