From beb6e154efd17f25427319efce0a672e8afcb6d0 Mon Sep 17 00:00:00 2001 From: Bianca Nenciu Date: Tue, 5 Feb 2019 11:54:52 +0200 Subject: [PATCH] FIX: in:title should work irrespective of the order. (#6968) --- lib/search.rb | 3 +-- spec/components/search_spec.rb | 13 +++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/search.rb b/lib/search.rb index 61ccf79d91d..04f7315098d 100644 --- a/lib/search.rb +++ b/lib/search.rb @@ -157,6 +157,7 @@ class Search term.gsub!(/[\u201c\u201d]/, '"') @clean_term = term + @in_title = false term = process_advanced_search!(term) @@ -551,8 +552,6 @@ class Search end end - @in_title = false - if word == 'order:latest' || word == 'l' @order = :latest nil diff --git a/spec/components/search_spec.rb b/spec/components/search_spec.rb index ce6088a0a99..70b9ea8ab2d 100644 --- a/spec/components/search_spec.rb +++ b/spec/components/search_spec.rb @@ -1053,6 +1053,19 @@ describe Search do results = Search.execute('first in:title') expect(results.posts.length).to eq(0) end + + it 'works irrespective of the order' do + topic = Fabricate(:topic, title: "A topic about Discourse") + Fabricate(:post, topic: topic, raw: "This is another post") + topic2 = Fabricate(:topic, title: "This is another topic") + Fabricate(:post, topic: topic2, raw: "Discourse is awesome") + + results = Search.execute('Discourse in:title status:open') + expect(results.posts.length).to eq(1) + + results = Search.execute('in:title status:open Discourse') + expect(results.posts.length).to eq(1) + end end context 'ignore_diacritics' do