summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Davis <edavis@littlestreamsoftware.com>2010-01-23 16:50:41 +0000
committerEric Davis <edavis@littlestreamsoftware.com>2010-01-23 16:50:41 +0000
commita8f56aad2c9455950cd14408e74c4ecdc993ed60 (patch)
treebc70bf4eed5afb02820896372341fc5048ca1b8a
parentd4525828b9d8d2aac8f17717af0ea59184f38542 (diff)
downloadredmine-a8f56aad2c9455950cd14408e74c4ecdc993ed60.tar.gz
redmine-a8f56aad2c9455950cd14408e74c4ecdc993ed60.zip
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
-rw-r--r--test/object_daddy_helpers.rb17
1 files changed, 16 insertions, 1 deletions
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