提交 dcee87c9 编写于 作者: M Miguel Grazziotin

[#20338] WIP: first basic implementation and specs

上级 f7c0d133
......@@ -459,7 +459,11 @@ def find_some(ids)
end
if result.size == expected_size
result
# 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] }
else
raise_record_not_found_exception!(ids, result.size, expected_size)
end
......
......@@ -48,6 +48,18 @@ def test_find_with_proc_parameter_and_block
end
end
def test_find_with_ids_returning_ordered
records = Topic.find([4,2,5])
assert_equal 'The Fourth Topic of the day', records[0].title
assert_equal 'The Second Topic of the day', records[1].title
assert_equal 'The Fifth Topic of the day', records[2].title
records = Topic.find(4,2,5)
assert_equal 'The Fourth Topic of the day', records[0].title
assert_equal 'The Second Topic of the day', records[1].title
assert_equal 'The Fifth Topic of the day', records[2].title
end
def test_find_passing_active_record_object_is_deprecated
assert_deprecated do
Topic.find(Topic.last)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册