Added and updated some more object daddy exemplars.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3342 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
675f28f895
commit
8420f25109
|
@ -0,0 +1,21 @@
|
||||||
|
class Attachment < ActiveRecord::Base
|
||||||
|
generator_for :container, :method => :generate_project
|
||||||
|
generator_for :file, :method => :generate_file
|
||||||
|
generator_for :author, :method => :generate_author
|
||||||
|
|
||||||
|
def self.generate_project
|
||||||
|
Project.generate!
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.generate_author
|
||||||
|
User.generate_with_protected!
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.generate_file
|
||||||
|
@file = 'a_file.png'
|
||||||
|
@file.stubs(:original_filename).returns('a_file.png')
|
||||||
|
@file.stubs(:content_type).returns('image/png')
|
||||||
|
@file.stubs(:read).returns(false)
|
||||||
|
@file
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,13 @@
|
||||||
|
class Comment < ActiveRecord::Base
|
||||||
|
generator_for :commented, :method => :generate_news
|
||||||
|
generator_for :author, :method => :generate_author
|
||||||
|
generator_for :comments => 'What great news this is.'
|
||||||
|
|
||||||
|
def self.generate_news
|
||||||
|
News.generate!
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.generate_author
|
||||||
|
User.generate_with_protected!
|
||||||
|
end
|
||||||
|
end
|
|
@ -1,2 +1,7 @@
|
||||||
class CustomValue < ActiveRecord::Base
|
class CustomValue < ActiveRecord::Base
|
||||||
|
generator_for :custom_field, :method => :generate_custom_field
|
||||||
|
|
||||||
|
def self.generate_custom_field
|
||||||
|
CustomField.generate!
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
class Group < Principal
|
||||||
|
generator_for :lastname, :method => :next_lastname
|
||||||
|
|
||||||
|
def self.next_lastname
|
||||||
|
@last_lastname ||= 'Group'
|
||||||
|
@last_lastname.succ!
|
||||||
|
@last_lastname
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
|
@ -0,0 +1,13 @@
|
||||||
|
class Journal < ActiveRecord::Base
|
||||||
|
generator_for :journalized, :method => :generate_issue
|
||||||
|
generator_for :user, :method => :generate_user
|
||||||
|
|
||||||
|
def self.generate_issue
|
||||||
|
project = Project.generate!
|
||||||
|
Issue.generate_for_project!(project)
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.generate_user
|
||||||
|
User.generate_with_protected!
|
||||||
|
end
|
||||||
|
end
|
|
@ -1,2 +1,12 @@
|
||||||
class Member < ActiveRecord::Base
|
class Member < ActiveRecord::Base
|
||||||
|
generator_for :roles, :method => :generate_roles
|
||||||
|
generator_for :principal, :method => :generate_user
|
||||||
|
|
||||||
|
def self.generate_roles
|
||||||
|
[Role.generate!]
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.generate_user
|
||||||
|
User.generate_with_protected!
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue