Commit 1e833567 authored by edavis10's avatar edavis10

Moved object daddy helpers to their own module.

git-svn-id: https://svn.redmine.org/redmine/trunk@2938 e93f8b46-1217-0410-a6f0-8f06a7374b81
parent 46552e60
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
......@@ -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
......
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