You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

object_daddy_helpers.rb 900B

12345678910111213141516171819202122232425262728293031323334
  1. module ObjectDaddyHelpers
  2. # TODO: Remove these three once everyone has ported their code to use the
  3. # new object_daddy version with protected attribute support
  4. def User.generate_with_protected(attributes={})
  5. User.generate(attributes)
  6. end
  7. def User.generate_with_protected!(attributes={})
  8. User.generate!(attributes)
  9. end
  10. def User.spawn_with_protected(attributes={})
  11. User.spawn(attributes)
  12. end
  13. # Generate the default Query
  14. def Query.generate_default!(attributes={})
  15. query = Query.spawn(attributes)
  16. query.name ||= '_'
  17. query.save!
  18. query
  19. end
  20. # Generate an issue for a project, using it's trackers
  21. def Issue.generate_for_project!(project, attributes={})
  22. issue = Issue.spawn(attributes) do |issue|
  23. issue.project = project
  24. end
  25. issue.tracker = project.trackers.first unless project.trackers.empty?
  26. issue.save!
  27. issue
  28. end
  29. end