diff --git a/app/models/guide_card.rb b/app/models/guide_card.rb index 05a3eed..7115e62 100644 --- a/app/models/guide_card.rb +++ b/app/models/guide_card.rb @@ -7,7 +7,7 @@ class GuideCard < ApplicationRecord # First, try to find an exact match. Otherwise, find the closest match. def self.search_result(term) - match = GuideCard.find_by(heading: term) + match = GuideCard.find_by('heading ilike ?', term) return match if match.present? GuideCard.where('heading < ?', term).order(heading: :desc).limit(1).first diff --git a/spec/system/search_feature_spec.rb b/spec/system/search_feature_spec.rb index 1b80ae1..02a8035 100644 --- a/spec/system/search_feature_spec.rb +++ b/spec/system/search_feature_spec.rb @@ -31,5 +31,11 @@ click_on '1' expect(page).to have_link('AALAS') end + it 'ignores capitalization' do + visit '/' + fill_in 'search_term', with: 'aaron' + click_on 'Go' + expect(page).to have_link('* Aaron') + end end end