annotate test/.svn/text-base/object_daddy_helpers.rb.svn-base @ 8:0c83d98252d9 yuya

* Add custom repo prefix and proper auth realm, remove auth cache (seems like an unwise feature), pass DB handle around, various other bits of tidying
author Chris Cannam
date Thu, 12 Aug 2010 15:31:37 +0100
parents 513646585e45
children 40f7cfd4df19
rev   line source
Chris@0 1 module ObjectDaddyHelpers
Chris@0 2 # TODO: Remove these three once everyone has ported their code to use the
Chris@0 3 # new object_daddy version with protected attribute support
Chris@0 4 def User.generate_with_protected(attributes={})
Chris@0 5 User.generate(attributes)
Chris@0 6 end
Chris@0 7
Chris@0 8 def User.generate_with_protected!(attributes={})
Chris@0 9 User.generate!(attributes)
Chris@0 10 end
Chris@0 11
Chris@0 12 def User.spawn_with_protected(attributes={})
Chris@0 13 User.spawn(attributes)
Chris@0 14 end
Chris@0 15
Chris@0 16 # Generate the default Query
Chris@0 17 def Query.generate_default!(attributes={})
Chris@0 18 query = Query.spawn(attributes)
Chris@0 19 query.name ||= '_'
Chris@0 20 query.save!
Chris@0 21 query
Chris@0 22 end
Chris@0 23
Chris@0 24 # Generate an issue for a project, using it's trackers
Chris@0 25 def Issue.generate_for_project!(project, attributes={})
Chris@0 26 issue = Issue.spawn(attributes) do |issue|
Chris@0 27 issue.project = project
Chris@0 28 end
Chris@0 29 issue.tracker = project.trackers.first unless project.trackers.empty?
Chris@0 30 issue.save!
Chris@0 31 issue
Chris@0 32 end
Chris@0 33
Chris@0 34 end