Skip to content

Commit

Permalink
Replace .where with in_order_of for results method (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
decaffeinatedio authored Aug 28, 2024
1 parent ca781c4 commit babf321
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/redi_search/search.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions test/unit/redi_search/search_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit babf321

Please sign in to comment.