Skip to content

A platform for community discussion. Free, open, simple.

DEV: Improve search phrase spec to show that it actually works.

Guo Xiang Tan179982025641
diff --git a/spec/components/search_spec.rb b/spec/components/search_spec.rb
index 523eb9b8a62..a3b8674fa16 100644
--- a/spec/components/search_spec.rb
+++ b/spec/components/search_spec.rb
@@ -850,11 +850,13 @@ describe Search do
end
it 'can search numbers correctly, and match exact phrases' do
- topic = Fabricate(:topic, created_at: 3.months.ago)
- Fabricate(:post, raw: '3.0 eta is in 2 days horrah', topic: topic)
+ post = Fabricate(:post, raw: '3.0 eta is in 2 days horrah')
+ post2 = Fabricate(:post, raw: '3.0 is eta in 2 days horrah')
- expect(Search.execute('3.0 eta').posts.length).to eq(1)
- expect(Search.execute('"3.0, eta is"').posts.length).to eq(0)
+ expect(Search.execute('3.0 eta').posts).to contain_exactly(post, post2)
+ expect(Search.execute("'3.0 eta'").posts).to contain_exactly(post, post2)
+ expect(Search.execute("\"3.0 eta\"").posts).to contain_exactly(post)
+ expect(Search.execute('"3.0, eta is"').posts).to eq([])
end
it 'can find by status' do