summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Davis <edavis@littlestreamsoftware.com>2009-10-20 00:36:55 +0000
committerEric Davis <edavis@littlestreamsoftware.com>2009-10-20 00:36:55 +0000
commitb887cef7af15a4f108d6e29b0fd869ab9e98234f (patch)
treeec6676d7458e6fc683a793bc2df60cb778a62541
parent6456f7c4a4816b2db4da5a5f7e358517a66fe963 (diff)
downloadredmine-b887cef7af15a4f108d6e29b0fd869ab9e98234f.tar.gz
redmine-b887cef7af15a4f108d6e29b0fd869ab9e98234f.zip
Moved object daddy helpers to their own module.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2938 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r--test/object_daddy_helpers.rb33
-rw-r--r--test/test_helper.rb32
2 files changed, 35 insertions, 30 deletions
diff --git a/test/object_daddy_helpers.rb b/test/object_daddy_helpers.rb
new file mode 100644
index 000000000..a05e55f83
--- /dev/null
+++ b/test/object_daddy_helpers.rb
@@ -0,0 +1,33 @@
+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(attributes) do |user|
+ user.login = User.next_login
+ attributes.each do |attr,v|
+ user.send("#{attr}=", v)
+ end
+ end
+ user.save!
+ user
+ end
+
+ # Generate the default Query
+ def Query.generate_default!(attributes={})
+ query = Query.spawn(attributes)
+ query.name ||= '_'
+ query.save!
+ query
+ end
+
+ # Generate an issue for a project, using it's trackers
+ def Issue.generate_for_project!(project, attributes={})
+ issue = Issue.spawn(attributes) do |issue|
+ issue.project = project
+ end
+ issue.tracker = project.trackers.first unless project.trackers.empty?
+ issue.save!
+ issue
+ end
+
+end
diff --git a/test/test_helper.rb b/test/test_helper.rb
index 3a3b12424..07d4af778 100644
--- a/test/test_helper.rb
+++ b/test/test_helper.rb
@@ -21,36 +21,8 @@ require 'test_help'
require File.expand_path(File.dirname(__FILE__) + '/helper_testcase')
require File.join(RAILS_ROOT,'test', 'mocks', 'open_id_authentication_mock.rb')
-# 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(attributes) do |user|
- user.login = User.next_login
- attributes.each do |attr,v|
- user.send("#{attr}=", v)
- end
- end
- user.save!
- user
-end
-
-# Generate the default Query
-def Query.generate_default!(attributes={})
- query = Query.spawn(attributes)
- query.name ||= '_'
- query.save!
- query
-end
-
-# Generate an issue for a project, using it's trackers
-def Issue.generate_for_project!(project, attributes={})
- issue = Issue.spawn(attributes) do |issue|
- issue.project = project
- end
- issue.tracker = project.trackers.first unless project.trackers.empty?
- issue.save!
- issue
-end
+require File.expand_path(File.dirname(__FILE__) + '/object_daddy_helpers')
+include ObjectDaddyHelpers
class ActiveSupport::TestCase
# Transactional fixtures accelerate your tests by wrapping each test method