Merged the Object Daddy exemplars from trunk. r3337, r3340, r3342

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/0.9-stable@3359 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Eric Davis
2010-02-02 16:03:05 +00:00
parent 27fa40d283
commit 76d9d01db0
25 changed files with 310 additions and 1 deletions
+16 -1
View File
@@ -1,14 +1,29 @@
module ObjectDaddyHelpers
# TODO: The gem or official version of ObjectDaddy doesn't set
# protected attributes so they need to be wrapped.
def User.generate_with_protected(attributes={})
user = User.spawn_with_protected(attributes)
user.save
user
end
# TODO: The gem or official version of ObjectDaddy doesn't set
# protected attributes so they need to be wrapped.
def User.generate_with_protected!(attributes={})
user = User.spawn_with_protected(attributes)
user.save!
user
end
# TODO: The gem or official version of ObjectDaddy doesn't set
# protected attributes so they need to be wrapped.
def User.spawn_with_protected(attributes={})
user = User.spawn(attributes) do |user|
user.login = User.next_login
attributes.each do |attr,v|
user.send("#{attr}=", v)
end
end
user.save!
user
end