blob: 95b9d63b9d97072d6348297cc5951db5b8181594 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
module StubRecordHelper
# Create a stub that has the usual functions of a database record.
# It won't fail on rendering a form for example.
def stub_record(klass, params = {}, persisted = true)
if klass.respond_to?(:valid_attributes_hash)
params.reverse_merge!(klass.valid_attributes_hash)
end
params[:params] = params.stringify_keys
params.reverse_merge! :id => 123,
:class => klass,
:to_key => ['123'],
:new_record? => !persisted,
:persisted? => persisted
stub params
end
end
|