diff options
author | Yorick Peterse <yorickpeterse@gmail.com> | 2016-03-01 19:05:26 +0300 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2016-03-11 23:25:22 +0300 |
commit | 2cf7f3f410832560bf049b24fbcaa27c1e3f30c7 (patch) | |
tree | 39e97a7c0d99ac97b98ed28d11a12dae11c109d5 /spec/models/milestone_spec.rb | |
parent | 87e7c3e1321ac5ae26d6a23d7b16e8dadaff98d2 (diff) |
Use ILIKE/LIKE for searching milestones
Diffstat (limited to 'spec/models/milestone_spec.rb')
-rw-r--r-- | spec/models/milestone_spec.rb | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/spec/models/milestone_spec.rb b/spec/models/milestone_spec.rb index 28f13100d15..de1757bf67a 100644 --- a/spec/models/milestone_spec.rb +++ b/spec/models/milestone_spec.rb @@ -181,4 +181,34 @@ describe Milestone, models: true do expect(issue4.position).to eq(42) end end + + describe '.search' do + let(:milestone) { create(:milestone, title: 'foo', description: 'bar') } + + it 'returns milestones with a matching title' do + expect(described_class.search(milestone.title)).to eq([milestone]) + end + + it 'returns milestones with a partially matching title' do + expect(described_class.search(milestone.title[0..2])).to eq([milestone]) + end + + it 'returns milestones with a matching title regardless of the casing' do + expect(described_class.search(milestone.title.upcase)).to eq([milestone]) + end + + it 'returns milestones with a matching description' do + expect(described_class.search(milestone.description)).to eq([milestone]) + end + + it 'returns milestones with a partially matching description' do + expect(described_class.search(milestone.description[0..2])). + to eq([milestone]) + end + + it 'returns milestones with a matching description regardless of the casing' do + expect(described_class.search(milestone.description.upcase)). + to eq([milestone]) + end + end end |