Merge branch 'fix-filtering-username-with-multiple-words' into 'master'
Fix filtering usernames with multiple words Closes #27404 See merge request !8851
This commit is contained in:
commit
797ca1b15d
|
@ -39,8 +39,15 @@
|
|||
getSearchInput() {
|
||||
const query = gl.DropdownUtils.getSearchInput(this.input);
|
||||
const { lastToken } = gl.FilteredSearchTokenizer.processTokens(query);
|
||||
let value = lastToken.value || '';
|
||||
|
||||
return lastToken.value || '';
|
||||
// Removes the first character if it is a quotation so that we can search
|
||||
// with multiple words
|
||||
if (value[0] === '"' || value[0] === '\'') {
|
||||
value = value.slice(1);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
init() {
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
---
|
||||
title: Fix filtering usernames with multiple words
|
||||
merge_request: 8851
|
||||
author:
|
|
@ -0,0 +1,40 @@
|
|||
//= require filtered_search/dropdown_utils
|
||||
//= require filtered_search/filtered_search_tokenizer
|
||||
//= require filtered_search/filtered_search_dropdown
|
||||
//= require filtered_search/dropdown_user
|
||||
|
||||
(() => {
|
||||
describe('Dropdown User', () => {
|
||||
describe('getSearchInput', () => {
|
||||
let dropdownUser;
|
||||
|
||||
beforeEach(() => {
|
||||
spyOn(gl.FilteredSearchDropdown.prototype, 'constructor').and.callFake(() => {});
|
||||
spyOn(gl.DropdownUser.prototype, 'getProjectId').and.callFake(() => {});
|
||||
spyOn(gl.DropdownUtils, 'getSearchInput').and.callFake(() => {});
|
||||
|
||||
dropdownUser = new gl.DropdownUser();
|
||||
});
|
||||
|
||||
it('should not return the double quote found in value', () => {
|
||||
spyOn(gl.FilteredSearchTokenizer, 'processTokens').and.returnValue({
|
||||
lastToken: {
|
||||
value: '"johnny appleseed',
|
||||
},
|
||||
});
|
||||
|
||||
expect(dropdownUser.getSearchInput()).toBe('johnny appleseed');
|
||||
});
|
||||
|
||||
it('should not return the single quote found in value', () => {
|
||||
spyOn(gl.FilteredSearchTokenizer, 'processTokens').and.returnValue({
|
||||
lastToken: {
|
||||
value: '\'larry boy',
|
||||
},
|
||||
});
|
||||
|
||||
expect(dropdownUser.getSearchInput()).toBe('larry boy');
|
||||
});
|
||||
});
|
||||
});
|
||||
})();
|
Loading…
Reference in New Issue