diff options
| author | Yorick Peterse <yorickpeterse@gmail.com> | 2016-03-01 12:16:15 +0100 |
|---|---|---|
| committer | Robert Speicher <rspeicher@gmail.com> | 2016-03-11 15:25:21 -0500 |
| commit | db615d0a7992d5118c3e9e8914064eb26970666b (patch) | |
| tree | bbfb669878093f49579856a51a920cfa40a40a28 /spec/models | |
| parent | 135659a75135b47563b349d13a9846b9b017af15 (diff) | |
| download | gitlab-ce-db615d0a7992d5118c3e9e8914064eb26970666b.tar.gz | |
Use ILIKE in Project.search_by_title
Similar to the changes made to Project.search the method
Project.search_by_title now also uses Arel so it can automatically use
ILIKE/LIKE instead of the lower() function.
Diffstat (limited to 'spec/models')
| -rw-r--r-- | spec/models/project_spec.rb | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index 6627432aa83..59c5ffa6b9c 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -698,4 +698,20 @@ describe Project, models: true do project.expire_caches_before_rename('foo') end end + + describe '.search_by_title' do + let(:project) { create(:project, name: 'kittens') } + + it 'returns projects with a matching name' do + expect(described_class.search_by_title(project.name)).to eq([project]) + end + + it 'returns projects with a partially matching name' do + expect(described_class.search_by_title('kitten')).to eq([project]) + end + + it 'returns projects with a matching name regardless of the casing' do + expect(described_class.search_by_title('KITTENS')).to eq([project]) + end + end end |
