diff --git a/lib/redi_search/search.rb b/lib/redi_search/search.rb index 944e4a4..42101a3 100644 --- a/lib/redi_search/search.rb +++ b/lib/redi_search/search.rb @@ -23,7 +23,7 @@ def results if model no_content unless loaded? - model.where(id: to_a.map(&:document_id_without_index)) + model.in_order_of(:id, to_a.map(&:document_id_without_index)) else to_a end diff --git a/test/unit/redi_search/search_test.rb b/test/unit/redi_search/search_test.rb index 5a4a939..c3199e1 100644 --- a/test/unit/redi_search/search_test.rb +++ b/test/unit/redi_search/search_test.rb @@ -62,11 +62,11 @@ def active_record_relation_double end def search_with_model - model = Minitest::Mock.new.expect(:where, active_record_relation_double, - [], id: ["1"]) - Search.new( - Index.new(:users, model) { text_field :name }, "foo" - ).then { |search| yield search } + model = Minitest::Mock.new.expect(:in_order_of, + active_record_relation_double, + [:id, ["1"]]) + Search.new(Index.new(:users, model) { text_field :name }, + "foo").then { |search| yield search } assert_mock model end