Commit d6315335814a4b509d10e830ed5c20c8608ac054
1 parent
fa6a1841
Exists in
master
and in
5 other branches
Added warning for missing models keyword - #1487
Showing
2 changed files
with
17 additions
and
0 deletions
Show diff stats
lib/searchkick.rb
... | ... | @@ -128,6 +128,11 @@ 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 | + | |
131 | 136 | options = options.merge(block: block) if block |
132 | 137 | query = Searchkick::Query.new(klass, term, **options) |
133 | 138 | if options[:execute] == false | ... | ... |
test/multi_indices_test.rb
... | ... | @@ -41,6 +41,18 @@ class MultiIndicesTest < Minitest::Test |
41 | 41 | assert_includes error.message, "Use Searchkick.search" |
42 | 42 | end |
43 | 43 | |
44 | + def test_no_models_or_index_name | |
45 | + store_names ["Product A"] | |
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" | |
53 | + end | |
54 | + end | |
55 | + | |
44 | 56 | private |
45 | 57 | |
46 | 58 | def assert_search_multi(term, expected, options = {}) | ... | ... |