From 33ef240b39d261cd8a68f4240561a1850aa8e387 Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Sun, 14 Feb 2016 20:41:39 +0100 Subject: [PATCH] Search tags case insensitive fixes: #22352 * Added unit tests --- core/js/systemtags/systemtagscollection.js | 2 +- .../systemtags/systemtagsinputfieldSpec.js | 54 +++++++++++++++++++ 2 files changed, 55 insertions(+), 1 deletion(-) diff --git a/core/js/systemtags/systemtagscollection.js b/core/js/systemtags/systemtagscollection.js index 0f8a7aa980..8a5d309bac 100644 --- a/core/js/systemtags/systemtagscollection.js +++ b/core/js/systemtags/systemtagscollection.js @@ -11,7 +11,7 @@ (function(OC) { function filterFunction(model, term) { - return model.get('name').substr(0, term.length) === term; + return model.get('name').substr(0, term.length).toLowerCase() === term.toLowerCase(); } /** diff --git a/core/js/tests/specs/systemtags/systemtagsinputfieldSpec.js b/core/js/tests/specs/systemtags/systemtagsinputfieldSpec.js index 08470fbdd8..d62ef672f4 100644 --- a/core/js/tests/specs/systemtags/systemtagsinputfieldSpec.js +++ b/core/js/tests/specs/systemtags/systemtagsinputfieldSpec.js @@ -346,6 +346,7 @@ describe('OC.SystemTags.SystemTagsInputField tests', function() { new OC.SystemTags.SystemTagModel({id: '1', name: 'abc'}), new OC.SystemTags.SystemTagModel({id: '2', name: 'def'}), new OC.SystemTags.SystemTagModel({id: '3', name: 'abd', userAssignable: false}), + new OC.SystemTags.SystemTagModel({id: '4', name: 'Deg'}), ]); }); afterEach(function() { @@ -377,6 +378,32 @@ describe('OC.SystemTags.SystemTagsInputField tests', function() { } ]); }); + it('completes case insensitive', function() { + var callback = sinon.stub(); + opts.query({ + term: 'de', + callback: callback + }); + expect(fetchStub.calledOnce).toEqual(true); + + fetchStub.yieldTo('success', view.collection); + + expect(callback.calledOnce).toEqual(true); + expect(callback.getCall(0).args[0].results).toEqual([ + { + id: '2', + name: 'def', + userVisible: true, + userAssignable: true + }, + { + id: '4', + name: 'Deg', + userVisible: true, + userAssignable: true + } + ]); + }); }); }); @@ -446,6 +473,7 @@ describe('OC.SystemTags.SystemTagsInputField tests', function() { new OC.SystemTags.SystemTagModel({id: '1', name: 'abc'}), new OC.SystemTags.SystemTagModel({id: '2', name: 'def'}), new OC.SystemTags.SystemTagModel({id: '3', name: 'abd', userAssignable: false}), + new OC.SystemTags.SystemTagModel({id: '4', name: 'Deg'}), ]); }); afterEach(function() { @@ -471,6 +499,32 @@ describe('OC.SystemTags.SystemTagsInputField tests', function() { } ]); }); + it('completes case insensitive', function() { + var callback = sinon.stub(); + opts.query({ + term: 'de', + callback: callback + }); + expect(fetchStub.calledOnce).toEqual(true); + + fetchStub.yieldTo('success', view.collection); + + expect(callback.calledOnce).toEqual(true); + expect(callback.getCall(0).args[0].results).toEqual([ + { + id: '2', + name: 'def', + userVisible: true, + userAssignable: true + }, + { + id: '4', + name: 'Deg', + userVisible: true, + userAssignable: true + } + ]); + }); }); }); });