From 7e165d031b3edf353c9371bfd8b96504150183f1 Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Thu, 11 Aug 2016 11:52:53 -0400 Subject: [PATCH] FIX: Short terms will be searched for if at least one is long enough --- lib/search.rb | 1 - spec/components/search_spec.rb | 6 +++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/search.rb b/lib/search.rb index 020b58352ae..35e370b1e90 100644 --- a/lib/search.rb +++ b/lib/search.rb @@ -196,7 +196,6 @@ class Search @valid = false return end - @term = terms.join(' ') if @term.include?(' ') end # If the term is a number or url to a topic, just include that topic diff --git a/spec/components/search_spec.rb b/spec/components/search_spec.rb index 8c478b8b2e9..23d29ea53e9 100644 --- a/spec/components/search_spec.rb +++ b/spec/components/search_spec.rb @@ -67,7 +67,7 @@ describe Search do expect(search.term).to eq('') end - it 'does not search for multiple small terms' do + it 'needs at least one term that hits the length' do search = Search.new('a b c d', min_search_term_length: 5) search.execute expect(search.valid?).to eq(false) @@ -81,11 +81,11 @@ describe Search do expect(search.term).to eq('"a b c d"') end - it 'discards short terms' do + it 'searches for short terms if one hits the length' do search = Search.new('a b c okaylength', min_search_term_length: 5) search.execute expect(search.valid?).to eq(true) - expect(search.term).to eq('okaylength') + expect(search.term).to eq('a b c okaylength') end it 'escapes non alphanumeric characters' do