[#20338] improving implementation, fixing and adding some more specs
This commit is contained in:
parent
dcee87c9fc
commit
24389135b2
@ -459,11 +459,8 @@ def find_some(ids)
|
||||
end
|
||||
|
||||
if result.size == expected_size
|
||||
# result
|
||||
records_by_id = result.each_with_object(Hash.new) do |record, by_id|
|
||||
by_id[record.id] = record
|
||||
end
|
||||
ids.first(expected_size).collect { |id| records_by_id[id] }
|
||||
records_by_id = result.index_by(&:id)
|
||||
ids.first(expected_size).collect { |id| records_by_id[id.to_i] }
|
||||
else
|
||||
raise_record_not_found_exception!(ids, result.size, expected_size)
|
||||
end
|
||||
|
@ -521,7 +521,8 @@ def test_find_by_slug
|
||||
end
|
||||
|
||||
def test_find_by_slug_with_array
|
||||
assert_equal Topic.find(['1-meowmeow', '2-hello']), Topic.find([1, 2])
|
||||
assert_equal Topic.find([1, 2]), Topic.find(['1-meowmeow', '2-hello'])
|
||||
assert_equal 'The Second Topic of the day', Topic.find(['2-hello', '1-meowmeow']).first.title
|
||||
end
|
||||
|
||||
def test_find_by_slug_with_range
|
||||
|
Loading…
Reference in New Issue
Block a user