diff --git a/test/object_daddy_helpers.rb b/test/object_daddy_helpers.rb index a05e55f83..ce6e00bd7 100644 --- a/test/object_daddy_helpers.rb +++ b/test/object_daddy_helpers.rb @@ -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