summaryrefslogtreecommitdiff
path: root/users
diff options
context:
space:
mode:
authorAzul <azul@leap.se>2013-08-27 14:51:56 +0200
committerAzul <azul@leap.se>2013-08-27 14:57:44 +0200
commit0b8df3c03f440147f36858246e1003a2d0e2e54a (patch)
tree2d5ca15eccc05ad1af19d4d15045860a9ef56e8d /users
parent420bfb326f974eec14b04d6a170ed2d28c14180f (diff)
make sure find_record still works with real records
Diffstat (limited to 'users')
-rw-r--r--users/test/support/stub_record_helper.rb7
1 files changed, 3 insertions, 4 deletions
diff --git a/users/test/support/stub_record_helper.rb b/users/test/support/stub_record_helper.rb
index b3460d2..5bccb66 100644
--- a/users/test/support/stub_record_helper.rb
+++ b/users/test/support/stub_record_helper.rb
@@ -1,15 +1,14 @@
module StubRecordHelper
#
- # We will stub find_by_param or find to be called on klass and
+ # We will stub find_by_param or find_by_id to be called on klass and
# return the record given.
#
# If no record is given but a hash or nil will create a stub based on
# that instead and returns the stub.
#
- def find_record(factory, attribs_hash = {})
- attribs_hash = attribs_hash.reverse_merge(:id => Random.rand(10000).to_s)
- record = stub_record factory, attribs_hash
+ def find_record(factory, record_or_attribs_hash = {})
+ record = stub_record factory, record_or_attribs_hash, true
klass = record.class
finder = klass.respond_to?(:find_by_param) ? :find_by_param : :find
klass.stubs(finder).with(record.to_param.to_s).returns(record)