Commit 4464c3e5bedf3bf145c7a43a192b6eb857a6e1be
1 parent
75eb2aef
Exists in
relation
and in
1 other branch
Removed relation: true from tests
Showing
17 changed files
with
64 additions
and
66 deletions
Show diff stats
test/aggs_test.rb
... | ... | @@ -13,16 +13,16 @@ class AggsTest < Minitest::Test |
13 | 13 | |
14 | 14 | def test_basic |
15 | 15 | assert_equal ({1 => 1, 2 => 2}), store_agg(aggs: [:store_id]) |
16 | - assert_equal ({1 => 1, 2 => 2}), buckets_as_hash(Product.search("Product", relation: true).aggs(:store_id).aggs["store_id"]) | |
16 | + assert_equal ({1 => 1, 2 => 2}), buckets_as_hash(Product.search("Product").aggs(:store_id).aggs["store_id"]) | |
17 | 17 | end |
18 | 18 | |
19 | 19 | def test_where |
20 | 20 | assert_equal ({1 => 1}), store_agg(aggs: {store_id: {where: {in_stock: true}}}) |
21 | - assert_equal ({1 => 1}), buckets_as_hash(Product.search("Product", relation: true).aggs(store_id: {where: {in_stock: true}}).aggs["store_id"]) | |
21 | + assert_equal ({1 => 1}), buckets_as_hash(Product.search("Product").aggs(store_id: {where: {in_stock: true}}).aggs["store_id"]) | |
22 | 22 | end |
23 | 23 | |
24 | 24 | def test_relation |
25 | - relation = Product.search("Product", relation: true).aggs(:store_id).aggs(color: {where: {in_stock: true}}) | |
25 | + relation = Product.search("Product").aggs(:store_id).aggs(color: {where: {in_stock: true}}) | |
26 | 26 | assert_equal ["color", "store_id"], relation.aggs.keys.sort |
27 | 27 | end |
28 | 28 | |
... | ... | @@ -30,7 +30,7 @@ class AggsTest < Minitest::Test |
30 | 30 | agg = Product.search("Product", aggs: {color: {order: {_key: "desc"}}}).aggs["color"] |
31 | 31 | assert_equal %w(red green blue), agg["buckets"].map { |b| b["key"] } |
32 | 32 | |
33 | - agg = Product.search("Product", relation: true).aggs(color: {order: {_key: "desc"}}).aggs["color"] | |
33 | + agg = Product.search("Product").aggs(color: {order: {_key: "desc"}}).aggs["color"] | |
34 | 34 | assert_equal %w(red green blue), agg["buckets"].map { |b| b["key"] } |
35 | 35 | end |
36 | 36 | |
... | ... | @@ -110,7 +110,7 @@ class AggsTest < Minitest::Test |
110 | 110 | def test_smart_aggs_false |
111 | 111 | assert_equal ({2 => 2}), store_agg(where: {color: "red"}, aggs: {store_id: {where: {in_stock: false}}}, smart_aggs: false) |
112 | 112 | assert_equal ({2 => 2}), store_agg(where: {color: "blue"}, aggs: {store_id: {where: {in_stock: false}}}, smart_aggs: false) |
113 | - assert_equal ({2 => 2}), buckets_as_hash(Product.search("Product", relation: true).where(color: "red").aggs(store_id: {where: {in_stock: false}}).smart_aggs(false).aggs["store_id"]) | |
113 | + assert_equal ({2 => 2}), buckets_as_hash(Product.search("Product").where(color: "red").aggs(store_id: {where: {in_stock: false}}).smart_aggs(false).aggs["store_id"]) | |
114 | 114 | end |
115 | 115 | |
116 | 116 | def test_aggs_group_by_date | ... | ... |
test/autocomplete_test.rb
... | ... | @@ -4,19 +4,19 @@ class AutocompleteTest < Minitest::Test |
4 | 4 | def test_autocomplete |
5 | 5 | store_names ["Hummus"] |
6 | 6 | assert_search "hum", ["Hummus"], match: :text_start |
7 | - assert_search_relation ["Hummus"], Product.search("hum", relation: true).match(:text_start) | |
7 | + assert_search_relation ["Hummus"], Product.search("hum").match(:text_start) | |
8 | 8 | end |
9 | 9 | |
10 | 10 | def test_autocomplete_two_words |
11 | 11 | store_names ["Organic Hummus"] |
12 | 12 | assert_search "hum", [], match: :text_start |
13 | - assert_search_relation [], Product.search("hum", relation: true).match(:text_start) | |
13 | + assert_search_relation [], Product.search("hum").match(:text_start) | |
14 | 14 | end |
15 | 15 | |
16 | 16 | def test_autocomplete_fields |
17 | 17 | store_names ["Hummus"] |
18 | 18 | assert_search "hum", ["Hummus"], match: :text_start, fields: [:name] |
19 | - assert_search_relation ["Hummus"], Product.search("hum", relation: true).match(:text_start).fields(:name) | |
19 | + assert_search_relation ["Hummus"], Product.search("hum").match(:text_start).fields(:name) | |
20 | 20 | end |
21 | 21 | |
22 | 22 | def test_text_start |
... | ... | @@ -74,7 +74,7 @@ class AutocompleteTest < Minitest::Test |
74 | 74 | def test_exact |
75 | 75 | store_names ["hi@example.org"] |
76 | 76 | assert_search "hi@example.org", ["hi@example.org"], fields: [{name: :exact}] |
77 | - assert_search_relation ["hi@example.org"], Product.search("hi@example.org", relation: true).fields(name: :exact) | |
77 | + assert_search_relation ["hi@example.org"], Product.search("hi@example.org").fields(name: :exact) | |
78 | 78 | end |
79 | 79 | |
80 | 80 | def test_exact_case | ... | ... |
test/boost_test.rb
... | ... | @@ -11,7 +11,7 @@ class BoostTest < Minitest::Test |
11 | 11 | ] |
12 | 12 | assert_order "tomato", ["Tomato C", "Tomato B", "Tomato A"] |
13 | 13 | assert_equal_scores "tomato", conversions: false |
14 | - assert_equal 3, Product.search("tomato", relation: true).conversions(false).size | |
14 | + assert_equal 3, Product.search("tomato").conversions(false).size | |
15 | 15 | end |
16 | 16 | |
17 | 17 | def test_multiple_conversions |
... | ... | @@ -39,7 +39,7 @@ class BoostTest < Minitest::Test |
39 | 39 | |
40 | 40 | assert_order "speaker", ["Speaker A", "Speaker B", "Speaker C", "Speaker D"], {conversions: "conversions_a"}, Speaker |
41 | 41 | assert_order "speaker", ["Speaker D", "Speaker C", "Speaker B", "Speaker A"], {conversions: "conversions_a", conversions_term: "speaker_1"}, Speaker |
42 | - assert_order_relation ["Speaker D", "Speaker C", "Speaker B", "Speaker A"], Speaker.search("speaker", relation: true).conversions(:conversions_a).conversions_term("speaker_1") | |
42 | + assert_order_relation ["Speaker D", "Speaker C", "Speaker B", "Speaker A"], Speaker.search("speaker").conversions(:conversions_a).conversions_term("speaker_1") | |
43 | 43 | end |
44 | 44 | |
45 | 45 | def test_conversions_case |
... | ... | @@ -117,7 +117,7 @@ class BoostTest < Minitest::Test |
117 | 117 | ] |
118 | 118 | assert_order "tomato", ["Tomato C", "Tomato B", "Tomato A"], boost_by: [:orders_count] |
119 | 119 | assert_order "tomato", ["Tomato C", "Tomato B", "Tomato A"], boost_by: {orders_count: {factor: 10}} |
120 | - assert_order_relation ["Tomato C", "Tomato B", "Tomato A"], Product.search("tomato", relation: true).boost_by(orders_count: {factor: 10}) | |
120 | + assert_order_relation ["Tomato C", "Tomato B", "Tomato A"], Product.search("tomato").boost_by(orders_count: {factor: 10}) | |
121 | 121 | end |
122 | 122 | |
123 | 123 | def test_boost_by_missing |
... | ... | @@ -152,7 +152,7 @@ class BoostTest < Minitest::Test |
152 | 152 | assert_first "tomato", "Tomato B", boost_where: {user_ids: {value: [1, 4], factor: 10}} |
153 | 153 | assert_order "tomato", ["Tomato C", "Tomato B", "Tomato A"], boost_where: {user_ids: [{value: 1, factor: 10}, {value: 3, factor: 20}]} |
154 | 154 | |
155 | - assert_first_relation "Tomato B", Product.search("tomato", relation: true).boost_where(user_ids: 2) | |
155 | + assert_first_relation "Tomato B", Product.search("tomato").boost_where(user_ids: 2) | |
156 | 156 | end |
157 | 157 | |
158 | 158 | def test_boost_where_negative_boost |
... | ... | @@ -171,7 +171,7 @@ class BoostTest < Minitest::Test |
171 | 171 | {name: "Article 3", created_at: Time.now} |
172 | 172 | ] |
173 | 173 | assert_order "article", ["Article 3", "Article 2", "Article 1"], boost_by_recency: {created_at: {scale: "7d", decay: 0.5}} |
174 | - assert_order_relation ["Article 3", "Article 2", "Article 1"], Product.search("article", relation: true).boost_by_recency(created_at: {scale: "7d", decay: 0.5}) | |
174 | + assert_order_relation ["Article 3", "Article 2", "Article 1"], Product.search("article").boost_by_recency(created_at: {scale: "7d", decay: 0.5}) | |
175 | 175 | end |
176 | 176 | |
177 | 177 | def test_boost_by_recency_origin |
... | ... | @@ -190,7 +190,7 @@ class BoostTest < Minitest::Test |
190 | 190 | {name: "San Marino", latitude: 43.9333, longitude: 12.4667} |
191 | 191 | ] |
192 | 192 | assert_order "san", ["San Francisco", "San Antonio", "San Marino"], boost_by_distance: {field: :location, origin: [37, -122], scale: "1000mi"} |
193 | - assert_order_relation ["San Francisco", "San Antonio", "San Marino"], Product.search("san", relation: true).boost_by_distance(field: :location, origin: [37, -122], scale: "1000mi") | |
193 | + assert_order_relation ["San Francisco", "San Antonio", "San Marino"], Product.search("san").boost_by_distance(field: :location, origin: [37, -122], scale: "1000mi") | |
194 | 194 | end |
195 | 195 | |
196 | 196 | def test_boost_by_distance_hash |
... | ... | @@ -209,7 +209,7 @@ class BoostTest < Minitest::Test |
209 | 209 | {name: "San Marino", latitude: 43.9333, longitude: 12.4667} |
210 | 210 | ] |
211 | 211 | assert_order "san", ["San Francisco", "San Antonio", "San Marino"], boost_by_distance: {location: {origin: [37, -122], scale: "1000mi"}} |
212 | - assert_order_relation ["San Francisco", "San Antonio", "San Marino"], Product.search("san", relation: true).boost_by_distance(location: {origin: [37, -122], scale: "1000mi"}) | |
212 | + assert_order_relation ["San Francisco", "San Antonio", "San Marino"], Product.search("san").boost_by_distance(location: {origin: [37, -122], scale: "1000mi"}) | |
213 | 213 | end |
214 | 214 | |
215 | 215 | def test_boost_by_distance_v2_hash |
... | ... | @@ -240,6 +240,6 @@ class BoostTest < Minitest::Test |
240 | 240 | |
241 | 241 | assert_order "Rex", ["Rexx", "Rex"], {models: [Animal, Product], indices_boost: {Animal => 1, Product => 200}, fields: [:name]}, Searchkick |
242 | 242 | |
243 | - assert_order_relation ["Rexx", "Rex"], Searchkick.search("Rex", relation: true).models(Animal, Product).indices_boost(Animal => 1, Product => 200).fields(:name) | |
243 | + assert_order_relation ["Rexx", "Rex"], Searchkick.search("Rex").models(Animal, Product).indices_boost(Animal => 1, Product => 200).fields(:name) | |
244 | 244 | end |
245 | 245 | end | ... | ... |
test/highlight_test.rb
... | ... | @@ -4,7 +4,7 @@ class HighlightTest < Minitest::Test |
4 | 4 | def test_basic |
5 | 5 | store_names ["Two Door Cinema Club"] |
6 | 6 | assert_equal "Two Door <em>Cinema</em> Club", Product.search("cinema", highlight: true).highlights.first[:name] |
7 | - assert_equal "Two Door <em>Cinema</em> Club", Product.search("cinema", relation: true).highlight(true).highlights.first[:name] | |
7 | + assert_equal "Two Door <em>Cinema</em> Club", Product.search("cinema").highlight(true).highlights.first[:name] | |
8 | 8 | end |
9 | 9 | |
10 | 10 | def test_with_highlights |
... | ... | @@ -50,7 +50,7 @@ class HighlightTest < Minitest::Test |
50 | 50 | def test_multiple_words |
51 | 51 | store_names ["Hello World Hello"] |
52 | 52 | assert_equal "<em>Hello</em> World <em>Hello</em>", Product.search("hello", highlight: true).highlights.first[:name] |
53 | - assert_equal "<em>Hello</em> World <em>Hello</em>", Product.search("hello", relation: true).highlight(true).highlights.first[:name] | |
53 | + assert_equal "<em>Hello</em> World <em>Hello</em>", Product.search("hello").highlight(true).highlights.first[:name] | |
54 | 54 | end |
55 | 55 | |
56 | 56 | def test_encoder |
... | ... | @@ -61,7 +61,7 @@ class HighlightTest < Minitest::Test |
61 | 61 | def test_word_middle |
62 | 62 | store_names ["Two Door Cinema Club"] |
63 | 63 | assert_equal "Two Door <em>Cinema</em> Club", Product.search("ine", match: :word_middle, highlight: true).highlights.first[:name] |
64 | - assert_equal "Two Door <em>Cinema</em> Club", Product.search("ine", relation: true).match(:word_middle).highlight(true).highlights.first[:name] | |
64 | + assert_equal "Two Door <em>Cinema</em> Club", Product.search("ine").match(:word_middle).highlight(true).highlights.first[:name] | |
65 | 65 | end |
66 | 66 | |
67 | 67 | def test_body | ... | ... |
test/inheritance_test.rb
... | ... | @@ -32,7 +32,7 @@ class InheritanceTest < Minitest::Test |
32 | 32 | store_names ["Green Bear"], Dog |
33 | 33 | store_names ["Blue Bear"], Cat |
34 | 34 | assert_equal ["Blue Bear"], Animal.search("bear", type: [Cat]).map(&:name) |
35 | - assert_equal ["Blue Bear"], Animal.search("bear", relation: true).type(Cat).map(&:name) | |
35 | + assert_equal ["Blue Bear"], Animal.search("bear").type(Cat).map(&:name) | |
36 | 36 | end |
37 | 37 | |
38 | 38 | def test_force_multiple_types | ... | ... |
test/match_test.rb
... | ... | @@ -175,8 +175,8 @@ class MatchTest < Minitest::Test |
175 | 175 | def test_exclude_butter |
176 | 176 | store_names ["Butter Tub", "Peanut Butter Tub"] |
177 | 177 | assert_search "butter", ["Butter Tub"], exclude: ["peanut butter"] |
178 | - assert_search_relation ["Butter Tub"], Product.search("butter", relation: true).exclude("peanut butter") | |
179 | - assert_search_relation ["Butter Tub"], Product.search("butter", relation: true).exclude(["peanut butter"]) | |
178 | + assert_search_relation ["Butter Tub"], Product.search("butter").exclude("peanut butter") | |
179 | + assert_search_relation ["Butter Tub"], Product.search("butter").exclude(["peanut butter"]) | |
180 | 180 | end |
181 | 181 | |
182 | 182 | def test_exclude_butter_word_start | ... | ... |
test/misspellings_test.rb
... | ... | @@ -4,13 +4,13 @@ class MisspellingsTest < Minitest::Test |
4 | 4 | def test_misspellings |
5 | 5 | store_names ["abc", "abd", "aee"] |
6 | 6 | assert_search "abc", ["abc"], misspellings: false |
7 | - assert_search_relation ["abc"], Product.search("abc", relation: true).misspellings(false) | |
7 | + assert_search_relation ["abc"], Product.search("abc").misspellings(false) | |
8 | 8 | end |
9 | 9 | |
10 | 10 | def test_misspellings_distance |
11 | 11 | store_names ["abbb", "aabb"] |
12 | 12 | assert_search "aaaa", ["aabb"], misspellings: {distance: 2} |
13 | - assert_search_relation ["aabb"], Product.search("aaaa", relation: true).misspellings(distance: 2) | |
13 | + assert_search_relation ["aabb"], Product.search("aaaa").misspellings(distance: 2) | |
14 | 14 | end |
15 | 15 | |
16 | 16 | def test_misspellings_prefix_length | ... | ... |
test/multi_search_test.rb
... | ... | @@ -14,8 +14,8 @@ class MultiSearchTest < Minitest::Test |
14 | 14 | def test_basic_relation |
15 | 15 | store_names ["Product A"] |
16 | 16 | store_names ["Store A"], Store |
17 | - products = Product.search("*", relation: true) | |
18 | - stores = Store.search("*", relation: true) | |
17 | + products = Product.search("*") | |
18 | + stores = Store.search("*") | |
19 | 19 | Searchkick.multi_search([products, stores]) |
20 | 20 | assert_equal ["Product A"], products.map(&:name) |
21 | 21 | assert_equal ["Store A"], stores.map(&:name) | ... | ... |
test/order_test.rb
... | ... | @@ -5,14 +5,14 @@ class OrderTest < Minitest::Test |
5 | 5 | store_names ["Product A", "Product B", "Product C", "Product D"] |
6 | 6 | expected = ["Product D", "Product C", "Product B", "Product A"] |
7 | 7 | assert_order "product", expected, order: {name: :desc} |
8 | - assert_equal expected, Product.search("product", relation: true).order(name: :desc).map(&:name) | |
8 | + assert_equal expected, Product.search("product").order(name: :desc).map(&:name) | |
9 | 9 | end |
10 | 10 | |
11 | 11 | def test_order_string |
12 | 12 | store_names ["Product A", "Product B", "Product C", "Product D"] |
13 | 13 | expected = ["Product A", "Product B", "Product C", "Product D"] |
14 | 14 | assert_order "product", expected, order: "name" |
15 | - assert_equal expected, Product.search("product", relation: true).order("name").map(&:name) | |
15 | + assert_equal expected, Product.search("product").order("name").map(&:name) | |
16 | 16 | end |
17 | 17 | |
18 | 18 | def test_order_id |
... | ... | @@ -24,7 +24,7 @@ class OrderTest < Minitest::Test |
24 | 24 | expected = [product_a, product_b].sort_by { |r| r.id.to_s }.map(&:name) |
25 | 25 | assert_order "product", expected, order: {id: :asc} |
26 | 26 | # TODO fix in query? |
27 | - # assert_equal expected, Product.search("product", relation: true).order(id: :asc).map(&:name) | |
27 | + # assert_equal expected, Product.search("product").order(id: :asc).map(&:name) | |
28 | 28 | end |
29 | 29 | |
30 | 30 | def test_order_multiple |
... | ... | @@ -35,12 +35,12 @@ class OrderTest < Minitest::Test |
35 | 35 | ] |
36 | 36 | expected = ["Product A", "Product B", "Product C"] |
37 | 37 | assert_order "product", expected, order: {color: :asc, store_id: :desc} |
38 | - assert_equal expected, Product.search("product", relation: true).order(:color).order(store_id: :desc).map(&:name) | |
38 | + assert_equal expected, Product.search("product").order(:color).order(store_id: :desc).map(&:name) | |
39 | 39 | end |
40 | 40 | |
41 | 41 | def test_order_unmapped_type |
42 | 42 | assert_order "product", [], order: {not_mapped: {unmapped_type: "long"}} |
43 | - assert_search_relation [], Product.search("product", relation: true).order(not_mapped: {unmapped_type: "long"}) | |
43 | + assert_search_relation [], Product.search("product").order(not_mapped: {unmapped_type: "long"}) | |
44 | 44 | end |
45 | 45 | |
46 | 46 | def test_order_array | ... | ... |
test/pagination_test.rb
... | ... | @@ -45,7 +45,7 @@ class PaginationTest < Minitest::Test |
45 | 45 | |
46 | 46 | def test_pagination_relation |
47 | 47 | store_names ["Product A", "Product B", "Product C", "Product D", "Product E", "Product F"] |
48 | - products = Product.search("product", relation: true).order(name: :asc).page(2).per(2).padding(1) | |
48 | + products = Product.search("product").order(name: :asc).page(2).per(2).padding(1) | |
49 | 49 | assert_equal ["Product D", "Product E"], products.map(&:name) |
50 | 50 | assert_equal "product", products.entry_name |
51 | 51 | assert_equal 2, products.current_page | ... | ... |
test/query_test.rb
... | ... | @@ -12,22 +12,22 @@ class QueryTest < Minitest::Test |
12 | 12 | def test_body_options |
13 | 13 | store_names ["Milk", "Milk2"] |
14 | 14 | assert_search "milk", ["Milk", "Milk2"], body_options: {min_score: 0.0001} |
15 | - assert_search_relation ["Milk", "Milk2"], Product.search("milk", relation: true).body_options(min_score: 0.0001) | |
15 | + assert_search_relation ["Milk", "Milk2"], Product.search("milk").body_options(min_score: 0.0001) | |
16 | 16 | end |
17 | 17 | |
18 | 18 | def test_default_timeout |
19 | 19 | assert_equal "6s", Product.search("*", execute: false).body[:timeout] |
20 | - assert_equal "6s", Product.search("*", relation: true).body[:timeout] | |
20 | + assert_equal "6s", Product.search("*").body[:timeout] | |
21 | 21 | end |
22 | 22 | |
23 | 23 | def test_timeout_override |
24 | 24 | assert_equal "1s", Product.search("*", body_options: {timeout: "1s"}, execute: false).body[:timeout] |
25 | - assert_equal "1s", Product.search("*", relation: true).body_options(timeout: "1s").body[:timeout] | |
25 | + assert_equal "1s", Product.search("*").body_options(timeout: "1s").body[:timeout] | |
26 | 26 | end |
27 | 27 | |
28 | 28 | def test_request_params |
29 | 29 | assert_equal "dfs_query_then_fetch", Product.search("*", request_params: {search_type: "dfs_query_then_fetch"}, execute: false).params[:search_type] |
30 | - assert_equal "dfs_query_then_fetch", Product.search("*", relation: true).request_params(search_type: "dfs_query_then_fetch").params[:search_type] | |
30 | + assert_equal "dfs_query_then_fetch", Product.search("*").request_params(search_type: "dfs_query_then_fetch").params[:search_type] | |
31 | 31 | end |
32 | 32 | |
33 | 33 | def test_debug |
... | ... | @@ -41,7 +41,7 @@ class QueryTest < Minitest::Test |
41 | 41 | def test_debug_relation |
42 | 42 | store_names ["Milk"] |
43 | 43 | out, _ = capture_io do |
44 | - assert_search_relation ["Milk"], Product.search("milk", relation: true).debug(true) | |
44 | + assert_search_relation ["Milk"], Product.search("milk").debug(true) | |
45 | 45 | end |
46 | 46 | refute_includes out, "Error" |
47 | 47 | end | ... | ... |
test/relation_test.rb
... | ... | @@ -3,7 +3,7 @@ require_relative "test_helper" |
3 | 3 | class RelationTest < Minitest::Test |
4 | 4 | def test_works |
5 | 5 | store_names ["Product A", "Product B"] |
6 | - relation = Product.search("product", relation: true).where(name: "Product A").limit(1).offset(0).order(name: :desc) | |
6 | + relation = Product.search("product").where(name: "Product A").limit(1).offset(0).order(name: :desc) | |
7 | 7 | assert_equal ["Product A"], relation.map(&:name) |
8 | 8 | end |
9 | 9 | |
... | ... | @@ -14,7 +14,7 @@ class RelationTest < Minitest::Test |
14 | 14 | |
15 | 15 | def test_where |
16 | 16 | store_names ["Product A", "Product B"] |
17 | - assert_search_relation [], Product.search("*", relation: true).where(name: "Product A").where(name: "Product B") | |
17 | + assert_search_relation [], Product.search("*").where(name: "Product A").where(name: "Product B") | |
18 | 18 | end |
19 | 19 | |
20 | 20 | def test_parameters | ... | ... |
test/routing_test.rb
... | ... | @@ -5,7 +5,7 @@ class RoutingTest < Minitest::Test |
5 | 5 | query = Store.search("Dollar Tree", routing: "Dollar Tree", execute: false) |
6 | 6 | assert_equal query.params[:routing], "Dollar Tree" |
7 | 7 | |
8 | - query = Store.search("Dollar Tree", relation: true).routing("Dollar Tree") | |
8 | + query = Store.search("Dollar Tree").routing("Dollar Tree") | |
9 | 9 | assert_equal query.params[:routing], "Dollar Tree" |
10 | 10 | end |
11 | 11 | ... | ... |
test/scroll_test.rb
... | ... | @@ -75,7 +75,7 @@ class ScrollTest < Minitest::Test |
75 | 75 | def test_scroll_block_relation |
76 | 76 | store_names ["Product A", "Product B", "Product C", "Product D", "Product E", "Product F"] |
77 | 77 | batches_count = 0 |
78 | - Product.search("*", relation: true).per_page(2).scroll("1m") do |batch| | |
78 | + Product.search("*").per_page(2).scroll("1m") do |batch| | |
79 | 79 | assert_equal 2, batch.size |
80 | 80 | batches_count += 1 |
81 | 81 | end | ... | ... |
test/sql_test.rb
... | ... | @@ -5,14 +5,14 @@ class SqlTest < Minitest::Test |
5 | 5 | store_names ["Honey"] |
6 | 6 | assert_search "fresh honey", [] |
7 | 7 | assert_search "fresh honey", ["Honey"], operator: "or" |
8 | - assert_search_relation ["Honey"], Product.search("fresh honey", relation: true).operator(:or) | |
8 | + assert_search_relation ["Honey"], Product.search("fresh honey").operator(:or) | |
9 | 9 | end |
10 | 10 | |
11 | 11 | def test_operator_scoring |
12 | 12 | store_names ["Big Red Circle", "Big Green Circle", "Small Orange Circle"] |
13 | 13 | expected = ["Big Red Circle", "Big Green Circle", "Small Orange Circle"] |
14 | 14 | assert_order "big red circle", expected, operator: "or" |
15 | - assert_search_relation expected, Product.search("big red circle", relation: true).operator(:or) | |
15 | + assert_search_relation expected, Product.search("big red circle").operator(:or) | |
16 | 16 | end |
17 | 17 | |
18 | 18 | def test_fields_operator |
... | ... | @@ -25,7 +25,7 @@ class SqlTest < Minitest::Test |
25 | 25 | ] |
26 | 26 | expected = ["red", "blue", "cyan", "magenta"] |
27 | 27 | assert_search "red blue", expected, operator: "or", fields: ["color"] |
28 | - assert_search_relation expected, Product.search("red blue", relation: true).operator(:or).fields(:color) | |
28 | + assert_search_relation expected, Product.search("red blue").operator(:or).fields(:color) | |
29 | 29 | end |
30 | 30 | |
31 | 31 | def test_fields |
... | ... | @@ -34,7 +34,7 @@ class SqlTest < Minitest::Test |
34 | 34 | {name: "blue", color: "red fish"} |
35 | 35 | ] |
36 | 36 | assert_search "blue", ["red"], fields: ["color"] |
37 | - assert_equal ["red"], Product.search("blue", relation: true).fields(:color).map(&:name) | |
37 | + assert_equal ["red"], Product.search("blue").fields(:color).map(&:name) | |
38 | 38 | end |
39 | 39 | |
40 | 40 | def test_non_existent_field |
... | ... | @@ -56,7 +56,7 @@ class SqlTest < Minitest::Test |
56 | 56 | {name: "Product", latitude: 80.0} |
57 | 57 | ] |
58 | 58 | assert_search "product", ["Product"], where: {latitude: {gt: 79}} |
59 | - assert_search_relation ["Product"], Product.search("product", relation: true).where(latitude: {gt: 79}) | |
59 | + assert_search_relation ["Product"], Product.search("product").where(latitude: {gt: 79}) | |
60 | 60 | end |
61 | 61 | |
62 | 62 | # body_options |
... | ... | @@ -76,26 +76,26 @@ class SqlTest < Minitest::Test |
76 | 76 | def test_load_false |
77 | 77 | store_names ["Product A"] |
78 | 78 | assert_kind_of Hash, Product.search("product", load: false).first |
79 | - assert_kind_of Hash, Product.search("product", relation: true).load(false).first | |
79 | + assert_kind_of Hash, Product.search("product").load(false).first | |
80 | 80 | end |
81 | 81 | |
82 | 82 | def test_load_false_methods |
83 | 83 | store_names ["Product A"] |
84 | 84 | assert_equal "Product A", Product.search("product", load: false).first.name |
85 | - assert_equal "Product A", Product.search("product", relation: true).load(false).first.name | |
85 | + assert_equal "Product A", Product.search("product").load(false).first.name | |
86 | 86 | end |
87 | 87 | |
88 | 88 | def test_load_false_with_includes |
89 | 89 | store_names ["Product A"] |
90 | 90 | assert_kind_of Hash, Product.search("product", load: false, includes: [:store]).first |
91 | - assert_kind_of Hash, Product.search("product", relation: true).load(false).includes(:store).first | |
91 | + assert_kind_of Hash, Product.search("product").load(false).includes(:store).first | |
92 | 92 | end |
93 | 93 | |
94 | 94 | def test_load_false_nested_object |
95 | 95 | aisle = {"id" => 1, "name" => "Frozen"} |
96 | 96 | store [{name: "Product A", aisle: aisle}] |
97 | 97 | assert_equal aisle, Product.search("product", load: false).first.aisle.to_hash |
98 | - assert_equal aisle, Product.search("product", relation: true).load(false).first.aisle.to_hash | |
98 | + assert_equal aisle, Product.search("product").load(false).first.aisle.to_hash | |
99 | 99 | end |
100 | 100 | |
101 | 101 | # select |
... | ... | @@ -166,7 +166,7 @@ class SqlTest < Minitest::Test |
166 | 166 | |
167 | 167 | def test_select_relation |
168 | 168 | store [{name: "Product A", store_id: 1}] |
169 | - result = Product.search("product", relation: true).load(false).select(:name, :store_id).first | |
169 | + result = Product.search("product").load(false).select(:name, :store_id).first | |
170 | 170 | assert_equal %w(id name store_id), result.keys.reject { |k| k.start_with?("_") }.sort |
171 | 171 | assert_equal "Product A", result.name |
172 | 172 | assert_equal 1, result.store_id |
... | ... | @@ -174,13 +174,13 @@ class SqlTest < Minitest::Test |
174 | 174 | |
175 | 175 | def test_select_array_relation |
176 | 176 | store [{name: "Product A", user_ids: [1, 2]}] |
177 | - result = Product.search("product", relation: true).load(false).select(:user_ids).first | |
177 | + result = Product.search("product").load(false).select(:user_ids).first | |
178 | 178 | assert_equal [1, 2], result.user_ids |
179 | 179 | end |
180 | 180 | |
181 | 181 | def test_select_single_field_relation |
182 | 182 | store [{name: "Product A", store_id: 1}] |
183 | - result = Product.search("product", relation: true).load(false).select(:name).first | |
183 | + result = Product.search("product").load(false).select(:name).first | |
184 | 184 | assert_equal %w(id name), result.keys.reject { |k| k.start_with?("_") }.sort |
185 | 185 | assert_equal "Product A", result.name |
186 | 186 | assert_nil result.store_id |
... | ... | @@ -188,20 +188,20 @@ class SqlTest < Minitest::Test |
188 | 188 | |
189 | 189 | def test_select_all_relation |
190 | 190 | store [{name: "Product A", user_ids: [1, 2]}] |
191 | - hit = Product.search("product", relation: true).select(true).hits.first | |
191 | + hit = Product.search("product").select(true).hits.first | |
192 | 192 | assert_equal hit["_source"]["name"], "Product A" |
193 | 193 | assert_equal hit["_source"]["user_ids"], [1, 2] |
194 | 194 | end |
195 | 195 | |
196 | 196 | def test_select_none_relation |
197 | 197 | store [{name: "Product A", user_ids: [1, 2]}] |
198 | - hit = Product.search("product", relation: true).select(false).hits.first | |
198 | + hit = Product.search("product").select(false).hits.first | |
199 | 199 | assert_nil hit["_source"] |
200 | 200 | end |
201 | 201 | |
202 | 202 | def test_select_includes_relation |
203 | 203 | store [{name: "Product A", user_ids: [1, 2]}] |
204 | - result = Product.search("product", relation: true).load(false).select(includes: [:name]).first | |
204 | + result = Product.search("product").load(false).select(includes: [:name]).first | |
205 | 205 | assert_equal %w(id name), result.keys.reject { |k| k.start_with?("_") }.sort |
206 | 206 | assert_equal "Product A", result.name |
207 | 207 | assert_nil result.store_id |
... | ... | @@ -209,7 +209,7 @@ class SqlTest < Minitest::Test |
209 | 209 | |
210 | 210 | def test_select_excludes_relation |
211 | 211 | store [{name: "Product A", user_ids: [1, 2], store_id: 1}] |
212 | - result = Product.search("product", relation: true).load(false).select(excludes: [:name]).first | |
212 | + result = Product.search("product").load(false).select(excludes: [:name]).first | |
213 | 213 | assert_nil result.name |
214 | 214 | assert_equal [1, 2], result.user_ids |
215 | 215 | assert_equal 1, result.store_id |
... | ... | @@ -218,7 +218,7 @@ class SqlTest < Minitest::Test |
218 | 218 | def test_select_include_and_excludes_relation |
219 | 219 | # let's take this to the next level |
220 | 220 | store [{name: "Product A", user_ids: [1, 2], store_id: 1}] |
221 | - result = Product.search("product", relation: true).load(false).select(includes: [:store_id], excludes: [:name]).first | |
221 | + result = Product.search("product").load(false).select(includes: [:store_id], excludes: [:name]).first | |
222 | 222 | assert_equal 1, result.store_id |
223 | 223 | assert_nil result.name |
224 | 224 | assert_nil result.user_ids |
... | ... | @@ -229,7 +229,7 @@ class SqlTest < Minitest::Test |
229 | 229 | def test_nested_search |
230 | 230 | store [{name: "Product A", aisle: {"id" => 1, "name" => "Frozen"}}], Speaker |
231 | 231 | assert_search "frozen", ["Product A"], {fields: ["aisle.name"]}, Speaker |
232 | - assert_equal ["Product A"], Speaker.search("frozen", relation: true).fields("aisle.name").map(&:name) | |
232 | + assert_equal ["Product A"], Speaker.search("frozen").fields("aisle.name").map(&:name) | |
233 | 233 | end |
234 | 234 | |
235 | 235 | # other tests |
... | ... | @@ -239,7 +239,7 @@ class SqlTest < Minitest::Test |
239 | 239 | |
240 | 240 | store_names ["Product A"] |
241 | 241 | assert Product.search("product", includes: [:store]).first.association(:store).loaded? |
242 | - assert Product.search("product", relation: true).includes(:store).first.association(:store).loaded? | |
242 | + assert Product.search("product").includes(:store).first.association(:store).loaded? | |
243 | 243 | end |
244 | 244 | |
245 | 245 | def test_model_includes |
... | ... | @@ -256,7 +256,7 @@ class SqlTest < Minitest::Test |
256 | 256 | assert records.first.association(associations[klass].first).loaded? |
257 | 257 | end |
258 | 258 | |
259 | - result = Searchkick.search("*", relation: true).models(Product, Store).model_includes(associations) | |
259 | + result = Searchkick.search("*").models(Product, Store).model_includes(associations) | |
260 | 260 | assert_equal 2, result.length |
261 | 261 | result.group_by(&:class).each_pair do |klass, records| |
262 | 262 | assert records.first.association(associations[klass].first).loaded? |
... | ... | @@ -268,6 +268,6 @@ class SqlTest < Minitest::Test |
268 | 268 | |
269 | 269 | store_names ["Product A", "Product B"] |
270 | 270 | assert_search "product", ["Product A"], scope_results: ->(r) { r.where(name: "Product A") } |
271 | - assert_equal ["Product A"], Product.search("product", relation: true).load(->(r) { r.where(name: "Product A") }).map(&:name) | |
271 | + assert_equal ["Product A"], Product.search("product").load(->(r) { r.where(name: "Product A") }).map(&:name) | |
272 | 272 | end |
273 | 273 | end | ... | ... |
test/suggest_test.rb
... | ... | @@ -9,7 +9,7 @@ class SuggestTest < Minitest::Test |
9 | 9 | def test_basic |
10 | 10 | store_names ["Great White Shark", "Hammerhead Shark", "Tiger Shark"] |
11 | 11 | assert_suggest "How Big is a Tigre Shar", "how big is a tiger shark", fields: [:name] |
12 | - assert Product.search("How Big is a Tigre Shar", relation: true).suggest(true).fields(:name).suggestions.include?("how big is a tiger shark") | |
12 | + assert Product.search("How Big is a Tigre Shar").suggest(true).fields(:name).suggestions.include?("how big is a tiger shark") | |
13 | 13 | end |
14 | 14 | |
15 | 15 | def test_perfect | ... | ... |
test/test_helper.rb
... | ... | @@ -14,8 +14,6 @@ Searchkick.client.transport.logger = $logger |
14 | 14 | Searchkick.search_timeout = 5 |
15 | 15 | Searchkick.index_suffix = ENV["TEST_ENV_NUMBER"] # for parallel tests |
16 | 16 | |
17 | -# Searchkick.relation = ENV["RELATION"] | |
18 | - | |
19 | 17 | # add to elasticsearch-7.0.0/config/ |
20 | 18 | Searchkick.wordnet_path = "wn_s.pl" if ENV["WORDNET"] |
21 | 19 | ... | ... |