Commit 0d13873ebcb9a8f047bc24c71a3dc6a742ffdf14
1 parent
45a027e4
Exists in
master
and in
5 other branches
Moved tests [skip ci]
Showing
3 changed files
with
35 additions
and
26 deletions
Show diff stats
test/boost_test.rb
@@ -52,6 +52,14 @@ class BoostTest < Minitest::Test | @@ -52,6 +52,14 @@ class BoostTest < Minitest::Test | ||
52 | assert_order "red", ["Red", "White"], fields: [{"name^10" => :word_start}, "color"] | 52 | assert_order "red", ["Red", "White"], fields: [{"name^10" => :word_start}, "color"] |
53 | end | 53 | end |
54 | 54 | ||
55 | + # for issue #855 | ||
56 | + def test_boost_fields_apostrophes | ||
57 | + store_names ["Valentine's Day Special"] | ||
58 | + assert_search "Valentines", ["Valentine's Day Special"], fields: ["name^5"] | ||
59 | + assert_search "Valentine's", ["Valentine's Day Special"], fields: ["name^5"] | ||
60 | + assert_search "Valentine", ["Valentine's Day Special"], fields: ["name^5"] | ||
61 | + end | ||
62 | + | ||
55 | def test_boost_by | 63 | def test_boost_by |
56 | store [ | 64 | store [ |
57 | {name: "Tomato A"}, | 65 | {name: "Tomato A"}, |
test/match_test.rb
@@ -208,6 +208,14 @@ class MatchTest < Minitest::Test | @@ -208,6 +208,14 @@ class MatchTest < Minitest::Test | ||
208 | assert_search "ben and jerry's", ["Ben and Jerrys"] | 208 | assert_search "ben and jerry's", ["Ben and Jerrys"] |
209 | end | 209 | end |
210 | 210 | ||
211 | + # for issue #855 | ||
212 | + def test_apostrophes | ||
213 | + store_names ["Valentine's Day Special"] | ||
214 | + assert_search "Valentines", ["Valentine's Day Special"], fields: ["name^5"] | ||
215 | + assert_search "Valentine's", ["Valentine's Day Special"], fields: ["name^5"] | ||
216 | + assert_search "Valentine", ["Valentine's Day Special"], fields: ["name^5"] | ||
217 | + end | ||
218 | + | ||
211 | def test_ampersand_index | 219 | def test_ampersand_index |
212 | store_names ["Ben & Jerry's"] | 220 | store_names ["Ben & Jerry's"] |
213 | assert_search "ben and jerrys", ["Ben & Jerry's"] | 221 | assert_search "ben and jerrys", ["Ben & Jerry's"] |
@@ -310,30 +318,4 @@ class MatchTest < Minitest::Test | @@ -310,30 +318,4 @@ class MatchTest < Minitest::Test | ||
310 | ] | 318 | ] |
311 | assert_first "blue", "Blue B", fields: [:name, :color] | 319 | assert_first "blue", "Blue B", fields: [:name, :color] |
312 | end | 320 | end |
313 | - | ||
314 | - # for issue #855 | ||
315 | - def test_apostrophes | ||
316 | - store_names ["Valentine's Day Special"] | ||
317 | - assert_search "Valentines", ["Valentine's Day Special"], fields: ["name^5"] | ||
318 | - assert_search "Valentine's", ["Valentine's Day Special"], fields: ["name^5"] | ||
319 | - assert_search "Valentine", ["Valentine's Day Special"], fields: ["name^5"] | ||
320 | - end | ||
321 | - | ||
322 | - # TODO find better place | ||
323 | - | ||
324 | - def test_search_relation | ||
325 | - _, stderr = capture_io { Product.search("*") } | ||
326 | - assert_equal "", stderr | ||
327 | - _, stderr = capture_io { Product.all.search("*") } | ||
328 | - assert_match "WARNING", stderr | ||
329 | - end | ||
330 | - | ||
331 | - def test_search_relation_default_scope | ||
332 | - Band.reindex | ||
333 | - | ||
334 | - _, stderr = capture_io { Band.search("*") } | ||
335 | - assert_equal "", stderr | ||
336 | - _, stderr = capture_io { Band.all.search("*") } | ||
337 | - assert_match "WARNING", stderr | ||
338 | - end | ||
339 | end | 321 | end |
@@ -0,0 +1,19 @@ | @@ -0,0 +1,19 @@ | ||
1 | +require_relative "test_helper" | ||
2 | + | ||
3 | +class ModelTest < Minitest::Test | ||
4 | + def test_search_relation | ||
5 | + _, stderr = capture_io { Product.search("*") } | ||
6 | + assert_equal "", stderr | ||
7 | + _, stderr = capture_io { Product.all.search("*") } | ||
8 | + assert_match "WARNING", stderr | ||
9 | + end | ||
10 | + | ||
11 | + def test_search_relation_default_scope | ||
12 | + Band.reindex | ||
13 | + | ||
14 | + _, stderr = capture_io { Band.search("*") } | ||
15 | + assert_equal "", stderr | ||
16 | + _, stderr = capture_io { Band.all.search("*") } | ||
17 | + assert_match "WARNING", stderr | ||
18 | + end | ||
19 | +end |