Commit a8f56aad authored by Eric Davis's avatar Eric Davis

Added User.spawn_with_protected to generate an unsaved User record.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3337 e93f8b46-1217-0410-a6f0-8f06a7374b81
parent d4525828
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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment