Commit df1364c890113259f26116389896e941eebbd81d
1 parent
d6315335
Exists in
master
and in
5 other branches
Improved error message
Showing
3 changed files
with
9 additions
and
12 deletions
Show diff stats
lib/searchkick.rb
... | ... | @@ -128,11 +128,6 @@ module Searchkick |
128 | 128 | end |
129 | 129 | end |
130 | 130 | |
131 | - # TODO raise ArgumentError in next major version | |
132 | - unless klass || options[:models] | |
133 | - Searchkick.warn("missing keyword: :models") | |
134 | - end | |
135 | - | |
136 | 131 | options = options.merge(block: block) if block |
137 | 132 | query = Searchkick::Query.new(klass, term, **options) |
138 | 133 | if options[:execute] == false | ... | ... |
lib/searchkick/results.rb
... | ... | @@ -231,7 +231,7 @@ module Searchkick |
231 | 231 | index_alias = index.split("_")[0..-2].join("_") |
232 | 232 | Array((options[:index_mapping] || {})[index_alias]) |
233 | 233 | end |
234 | - raise Searchkick::Error, "Unknown model for index: #{index}" unless models.any? | |
234 | + raise Searchkick::Error, "Unknown model for index: #{index}. Pass the `models` option to the search method." unless models.any? | |
235 | 235 | index_models[index] = models |
236 | 236 | end |
237 | 237 | ... | ... |
test/multi_indices_test.rb
... | ... | @@ -44,13 +44,15 @@ class MultiIndicesTest < Minitest::Test |
44 | 44 | def test_no_models_or_index_name |
45 | 45 | store_names ["Product A"] |
46 | 46 | |
47 | - # TODO raise ArgumentError in next major version | |
48 | - assert_output(nil, /missing keyword: :models/) do | |
49 | - error = assert_raises(Searchkick::Error) do | |
50 | - Searchkick.search("product").results | |
51 | - end | |
52 | - assert_includes error.message, "Unknown model" | |
47 | + error = assert_raises(Searchkick::Error) do | |
48 | + Searchkick.search("product").results | |
53 | 49 | end |
50 | + assert_includes error.message, "Unknown model" | |
51 | + end | |
52 | + | |
53 | + def test_no_models_or_index_name_load_false | |
54 | + store_names ["Product A"] | |
55 | + Searchkick.search("product", load: false).results | |
54 | 56 | end |
55 | 57 | |
56 | 58 | private | ... | ... |