Commit 92ee9c6d authored by jplang's avatar jplang

Renamed object_daddy_helper and removed exemplars.

git-svn-id: https://svn.redmine.org/redmine/trunk@9470 e93f8b46-1217-0410-a6f0-8f06a7374b81
parent 499768ff
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 = ActiveSupport::TestCase.mock_file
end
end
class AuthSource < ActiveRecord::Base
generator_for :name, :start => 'Auth0'
end
class Board < ActiveRecord::Base
generator_for :name, :start => 'A Forum'
generator_for :description, :start => 'Some description here'
generator_for :project, :method => :generate_project
def self.generate_project
Project.generate!
end
end
class Change < ActiveRecord::Base
generator_for :action => 'A'
generator_for :path, :start => 'test/dir/aaa0001'
generator_for :changeset, :method => :generate_changeset
def self.generate_changeset
Changeset.generate!
end
end
class Changeset < ActiveRecord::Base
generator_for :revision, :start => '1'
generator_for :committed_on => Date.today
generator_for :repository, :method => :generate_repository
def self.generate_repository
Repository::Subversion.generate!
end
end
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
class CustomField < ActiveRecord::Base
generator_for :name, :start => 'CustomField0'
generator_for :field_format => 'string'
end
class CustomValue < ActiveRecord::Base
generator_for :custom_field, :method => :generate_custom_field
def self.generate_custom_field
CustomField.generate!
end
end
class DocumentCategory < Enumeration
generator_for :name, :start => 'DocumentCategory0'
generator_for :type => 'DocumentCategory'
end
class Document < ActiveRecord::Base
generator_for :title, :start => 'Document001'
end
class EnabledModule < ActiveRecord::Base
generator_for :name, :start => 'module_001'
end
class Enumeration < ActiveRecord::Base
generator_for :name, :start => 'Enumeration0'
generator_for :type => 'TimeEntryActivity'
end
class Group < Principal
generator_for :lastname, :start => 'Group'
end
class IssueCategory < ActiveRecord::Base
generator_for :name, :start => 'Category 0001'
end
class Issue < ActiveRecord::Base
generator_for :subject, :start => 'Subject 0'
generator_for :author, :method => :next_author
generator_for :priority, :method => :fetch_priority
def self.next_author
User.generate_with_protected!
end
def self.fetch_priority
IssuePriority.first || IssuePriority.generate!
end
end
class IssuePriority < Enumeration
generator_for :name, :start => 'IssuePriority0'
generator_for :type => 'IssuePriority'
end
class IssueStatus < ActiveRecord::Base
generator_for :name, :start => 'Status 0'
end
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
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
class MemberRole < ActiveRecord::Base
generator_for :member, :method => :generate_member
generator_for :role, :method => :generate_role
def self.generate_role
Role.generate!
end
def self.generate_member
Member.generate!
end
end
class Message < ActiveRecord::Base
generator_for :subject, :start => 'A Message'
generator_for :content, :start => 'Some content here'
generator_for :board, :method => :generate_board
def self.generate_board
Board.generate!
end
end
class News < ActiveRecord::Base
generator_for :title, :start => 'A New Item'
generator_for :description, :start => 'Some content here'
end
class Project < ActiveRecord::Base
generator_for :name, :start => 'Project 0'
generator_for :identifier, :start => 'project-0000'
generator_for :enabled_modules, :method => :all_modules
generator_for :trackers, :method => :next_tracker
def self.all_modules
[].tap do |modules|
Redmine::AccessControl.available_project_modules.each do |name|
modules << EnabledModule.new(:name => name.to_s)
end
end
end
def self.next_tracker
[Tracker.generate!]
end
end
class Query < ActiveRecord::Base
generator_for :name, :start => 'Query 0'
end
class Repository < ActiveRecord::Base
generator_for :type => 'Subversion'
generator_for :url, :start => 'file:///test/svn'
generator_for :identifier, :start => 'repo1'
end
class Role < ActiveRecord::Base
generator_for :name, :start => 'Role0'
end
class Repository::Subversion < Repository
generator_for :type, :method => 'Subversion'
generator_for :url, :start => 'file:///test/svn'
end
class TimeEntryActivity < Enumeration
generator_for :name, :start => 'TimeEntryActivity0'
generator_for :type => 'TimeEntryActivity'
end
class TimeEntry < ActiveRecord::Base
generator_for(:spent_on) { Date.today }
generator_for(:hours) { (rand * 10).round(2) } # 0.01 to 9.99
generator_for :user, :method => :generate_user
def self.generate_user
User.generate_with_protected!
end
end
class Tracker < ActiveRecord::Base
generator_for :name, :start => 'Tracker 0'
end
class User < Principal
generator_for :login, :start => 'user1'
generator_for :mail, :method => :next_email
generator_for :firstname, :start => 'Bob'
generator_for :lastname, :start => 'Doe'
def self.next_email
@last_email ||= 'user1'
@last_email.succ!
"#{@last_email}@example.com"
end
end
class Version < ActiveRecord::Base
generator_for :name, :start => 'Version 1.0.0'
generator_for :status => 'open'
end
class Watcher < ActiveRecord::Base
generator_for :user, :method => :generate_user
def self.generate_user
User.generate_with_protected!
end
end
class WikiContent < ActiveRecord::Base
generator_for :text => 'Some content'
generator_for :page, :method => :generate_page
def self.generate_page
WikiPage.generate!
end
end
class Wiki < ActiveRecord::Base
generator_for :start_page => 'Start'
generator_for :project, :method => :generate_project
def self.generate_project
Project.generate!
end
end
class WikiPage < ActiveRecord::Base
generator_for :title, :start => 'AWikiPage'
generator_for :wiki, :method => :generate_wiki
def self.generate_wiki
Wiki.generate!
end
end
class WikiRedirect < ActiveRecord::Base
generator_for :title, :start => 'AWikiPage'
generator_for :redirects_to, :start => '/a/path/000001'
generator_for :wiki, :method => :generate_wiki
def self.generate_wiki
Wiki.generate!
end
end
module ObjectDaddyHelpers
module ObjectHelpers
# TODO: Remove these three once everyone has ported their code to use the
# new object_daddy version with protected attribute support
def User.generate_with_protected(attributes={})
......
......@@ -20,8 +20,8 @@ require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
require 'test_help'
require Rails.root.join('test', 'mocks', 'open_id_authentication_mock.rb').to_s
require File.expand_path(File.dirname(__FILE__) + '/object_daddy_helpers')
include ObjectDaddyHelpers
require File.expand_path(File.dirname(__FILE__) + '/object_helpers')
include ObjectHelpers
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