2009-10-20 04:36:55 +04:00
|
|
|
module ObjectDaddyHelpers
|
2010-02-08 21:53:12 +03:00
|
|
|
# TODO: Remove these three once everyone has ported their code to use the
|
|
|
|
# new object_daddy version with protected attribute support
|
2010-01-23 19:50:41 +03:00
|
|
|
def User.generate_with_protected(attributes={})
|
2010-02-08 21:53:12 +03:00
|
|
|
User.generate(attributes)
|
2010-01-23 19:50:41 +03:00
|
|
|
end
|
|
|
|
|
2009-10-20 04:36:55 +04:00
|
|
|
def User.generate_with_protected!(attributes={})
|
2010-02-08 21:53:12 +03:00
|
|
|
User.generate!(attributes)
|
2010-01-23 19:50:41 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
def User.spawn_with_protected(attributes={})
|
2010-02-08 21:53:12 +03:00
|
|
|
User.spawn(attributes)
|
2009-10-20 04:36:55 +04:00
|
|
|
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
|
2010-09-10 07:09:02 +04:00
|
|
|
issue.tracker = project.trackers.first unless project.trackers.empty?
|
|
|
|
yield issue if block_given?
|
2009-10-20 04:36:55 +04:00
|
|
|
end
|
|
|
|
issue.save!
|
|
|
|
issue
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|