@@ -91,6 +91,8 @@ def reset_indexes
9191
9292 context 'when :class_name is also present' do
9393 it 'loads results from the correct models' do
94+ allow ( MeiliSearch ::Rails . logger ) . to receive ( :warn ) . and_return ( nil )
95+
9496 results = MeiliSearch ::Rails . multi_search (
9597 'books' => { q : 'Steve' , index_uid : Book . index . uid , class_name : 'Book' } ,
9698 'products' => { q : 'palm' , limit : 1 , index_uid : Product . index . uid , class_name : 'Product' } ,
@@ -122,6 +124,18 @@ def reset_indexes
122124 end
123125
124126 context 'when class_name is specified' do
127+ let ( :logger ) { instance_double ( 'Logger' , warn : nil ) }
128+
129+ before do
130+ allow ( MeiliSearch ::Rails ) . to receive ( :logger ) . and_return ( logger )
131+ end
132+
133+ it 'warns about deprecation' do
134+ results = MeiliSearch ::Rails . multi_search ( Book . index . uid => { q : 'Steve' , class_name : 'Book' } )
135+ expect ( results . to_h [ Book . index . uid ] ) . to contain_exactly ( steve_jobs )
136+ expect ( logger ) . to have_received ( :warn ) . with ( a_string_matching ( ':class_name' ) )
137+ end
138+
125139 it 'returns ORM records' do
126140 results = MeiliSearch ::Rails . multi_search (
127141 Book . index . uid => { q : 'Steve' , class_name : 'Book' } ,
@@ -150,7 +164,7 @@ def reset_indexes
150164 it 'returns a mixture of ORM records and hashes' do
151165 results = MeiliSearch ::Rails . multi_search (
152166 Book => { q : 'Steve' } ,
153- Product . index . uid => { q : 'palm' , limit : 1 , class_name : ' Product' } ,
167+ Product . index . uid => { q : 'palm' , limit : 1 , collection : Product } ,
154168 Color . index . uid => { q : 'bl' }
155169 )
156170
@@ -184,7 +198,7 @@ def reset_indexes
184198 context 'with collections' do
185199 it 'fetches items from the given collection' do
186200 results = MeiliSearch ::Rails . multi_search (
187- Product . index . uid => { q : 'palm' , class_name : 'Product ', collection : Product . where ( 'tags LIKE "%terrible%"' ) } ,
201+ Product => { q : 'palm' , collection : Product . where ( 'tags LIKE "%terrible%"' ) } ,
188202 Color => { q : 'bl' , collection : Color . where ( short_name : 'bla' ) }
189203 )
190204
0 commit comments