+++ /dev/null
-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
+++ /dev/null
-class AuthSource < ActiveRecord::Base
- generator_for :name, :start => 'Auth0'
-
-end
+++ /dev/null
-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
+++ /dev/null
-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
+++ /dev/null
-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
+++ /dev/null
-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
+++ /dev/null
-class CustomField < ActiveRecord::Base
- generator_for :name, :start => 'CustomField0'
- generator_for :field_format => 'string'
-
-end
+++ /dev/null
-class CustomValue < ActiveRecord::Base
- generator_for :custom_field, :method => :generate_custom_field
-
- def self.generate_custom_field
- CustomField.generate!
- end
-end
+++ /dev/null
-class DocumentCategory < Enumeration
- generator_for :name, :start => 'DocumentCategory0'
- generator_for :type => 'DocumentCategory'
-
-end
+++ /dev/null
-class Document < ActiveRecord::Base
- generator_for :title, :start => 'Document001'
-
-end
+++ /dev/null
-class EnabledModule < ActiveRecord::Base
- generator_for :name, :start => 'module_001'
-
-end
+++ /dev/null
-class Enumeration < ActiveRecord::Base
- generator_for :name, :start => 'Enumeration0'
- generator_for :type => 'TimeEntryActivity'
-
-end
+++ /dev/null
-class Group < Principal
- generator_for :lastname, :start => 'Group'
-
-end
+++ /dev/null
-class IssueCategory < ActiveRecord::Base
- generator_for :name, :start => 'Category 0001'
-
-end
+++ /dev/null
-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
+++ /dev/null
-class IssuePriority < Enumeration
- generator_for :name, :start => 'IssuePriority0'
- generator_for :type => 'IssuePriority'
-
-end
+++ /dev/null
-class IssueStatus < ActiveRecord::Base
- generator_for :name, :start => 'Status 0'
-
-end
+++ /dev/null
-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
+++ /dev/null
-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
+++ /dev/null
-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
+++ /dev/null
-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
+++ /dev/null
-class News < ActiveRecord::Base
- generator_for :title, :start => 'A New Item'
- generator_for :description, :start => 'Some content here'
-
-end
+++ /dev/null
-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
+++ /dev/null
-class Query < ActiveRecord::Base
- generator_for :name, :start => 'Query 0'
-
-end
+++ /dev/null
-class Repository < ActiveRecord::Base
- generator_for :type => 'Subversion'
- generator_for :url, :start => 'file:///test/svn'
- generator_for :identifier, :start => 'repo1'
-end
+++ /dev/null
-class Role < ActiveRecord::Base
- generator_for :name, :start => 'Role0'
-
-end
+++ /dev/null
-class Repository::Subversion < Repository
- generator_for :type, :method => 'Subversion'
- generator_for :url, :start => 'file:///test/svn'
-
-end
+++ /dev/null
-class TimeEntryActivity < Enumeration
- generator_for :name, :start => 'TimeEntryActivity0'
- generator_for :type => 'TimeEntryActivity'
-
-end
+++ /dev/null
-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
+++ /dev/null
-class Tracker < ActiveRecord::Base
- generator_for :name, :start => 'Tracker 0'
-
-end
+++ /dev/null
-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
+++ /dev/null
-class Version < ActiveRecord::Base
- generator_for :name, :start => 'Version 1.0.0'
- generator_for :status => 'open'
-
-end
+++ /dev/null
-class Watcher < ActiveRecord::Base
- generator_for :user, :method => :generate_user
-
- def self.generate_user
- User.generate_with_protected!
- end
-end
+++ /dev/null
-class WikiContent < ActiveRecord::Base
- generator_for :text => 'Some content'
- generator_for :page, :method => :generate_page
-
- def self.generate_page
- WikiPage.generate!
- end
-end
+++ /dev/null
-class Wiki < ActiveRecord::Base
- generator_for :start_page => 'Start'
- generator_for :project, :method => :generate_project
-
- def self.generate_project
- Project.generate!
- end
-end
+++ /dev/null
-class WikiPage < ActiveRecord::Base
- generator_for :title, :start => 'AWikiPage'
- generator_for :wiki, :method => :generate_wiki
-
- def self.generate_wiki
- Wiki.generate!
- end
-end
+++ /dev/null
-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
+++ /dev/null
-module ObjectDaddyHelpers
- # 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={})
- User.generate(attributes)
- end
-
- def User.generate_with_protected!(attributes={})
- User.generate!(attributes)
- end
-
- def User.spawn_with_protected(attributes={})
- User.spawn(attributes)
- end
-
- def User.add_to_project(user, project, roles)
- roles = [roles] unless roles.is_a?(Array)
- Member.create!(:principal => user, :project => project, :roles => roles)
- end
-
- def User.generate!(attributes={})
- @generated_user_login ||= 'user0'
- @generated_user_login.succ!
- user = User.new(attributes)
- user.login = @generated_user_login if user.login.blank?
- user.mail = "#{@generated_user_login}@example.com" if user.mail.blank?
- user.firstname = "Bob" if user.firstname.blank?
- user.lastname = "Doe" if user.lastname.blank?
- yield user if block_given?
- user.save!
- user
- end
-
- def Group.generate!(attributes={})
- @generated_group_name ||= 'Group 0'
- @generated_group_name.succ!
- group = Group.new(attributes)
- group.lastname = @generated_group_name if group.lastname.blank?
- yield group if block_given?
- group.save!
- group
- end
-
- def Project.generate!(attributes={})
- @generated_project_identifier ||= 'project-0000'
- @generated_project_identifier.succ!
- project = Project.new(attributes)
- project.name = @generated_project_identifier if project.name.blank?
- project.identifier = @generated_project_identifier if project.identifier.blank?
- yield project if block_given?
- project.save!
- project
- end
-
- def Tracker.generate!(attributes={})
- @generated_tracker_name ||= 'Tracker 0'
- @generated_tracker_name.succ!
- tracker = Tracker.new(attributes)
- tracker.name = @generated_tracker_name if tracker.name.blank?
- yield tracker if block_given?
- tracker.save!
- tracker
- end
-
- def Role.generate!(attributes={})
- @generated_role_name ||= 'Role 0'
- @generated_role_name.succ!
- role = Role.new(attributes)
- role.name = @generated_role_name if role.name.blank?
- yield role if block_given?
- role.save!
- role
- end
-
- def Issue.generate!(attributes={})
- issue = Issue.new(attributes)
- issue.subject = 'Generated' if issue.subject.blank?
- issue.author ||= User.find(2)
- yield issue if block_given?
- issue.save!
- issue
- end
-
- def Version.generate!(attributes={})
- @generated_version_name ||= 'Version 0'
- @generated_version_name.succ!
- version = Version.new(attributes)
- version.name = @generated_version_name if version.name.blank?
- yield version if block_given?
- version.save!
- version
- end
-
- def AuthSource.generate!(attributes={})
- @generated_auth_source_name ||= 'Auth 0'
- @generated_auth_source_name.succ!
- source = AuthSource.new(attributes)
- source.name = @generated_auth_source_name if source.name.blank?
- yield source if block_given?
- source.save!
- source
- end
-
- # Generate the default Query
- def Query.generate_default!(attributes={})
- query = Query.new(attributes)
- query.name = '_' if query.name.blank?
- query.save!
- query
- end
-
- # Generate an issue for a project, using it's trackers
- def Issue.generate_for_project!(project, attributes={})
- issue = Issue.new(attributes) do |issue|
- issue.project = project
- issue.tracker = project.trackers.first unless project.trackers.empty?
- issue.subject = 'Generated' if issue.subject.blank?
- issue.author ||= User.find(2)
- yield issue if block_given?
- end
- issue.save!
- issue
- end
-end
--- /dev/null
+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={})
+ User.generate(attributes)
+ end
+
+ def User.generate_with_protected!(attributes={})
+ User.generate!(attributes)
+ end
+
+ def User.spawn_with_protected(attributes={})
+ User.spawn(attributes)
+ end
+
+ def User.add_to_project(user, project, roles)
+ roles = [roles] unless roles.is_a?(Array)
+ Member.create!(:principal => user, :project => project, :roles => roles)
+ end
+
+ def User.generate!(attributes={})
+ @generated_user_login ||= 'user0'
+ @generated_user_login.succ!
+ user = User.new(attributes)
+ user.login = @generated_user_login if user.login.blank?
+ user.mail = "#{@generated_user_login}@example.com" if user.mail.blank?
+ user.firstname = "Bob" if user.firstname.blank?
+ user.lastname = "Doe" if user.lastname.blank?
+ yield user if block_given?
+ user.save!
+ user
+ end
+
+ def Group.generate!(attributes={})
+ @generated_group_name ||= 'Group 0'
+ @generated_group_name.succ!
+ group = Group.new(attributes)
+ group.lastname = @generated_group_name if group.lastname.blank?
+ yield group if block_given?
+ group.save!
+ group
+ end
+
+ def Project.generate!(attributes={})
+ @generated_project_identifier ||= 'project-0000'
+ @generated_project_identifier.succ!
+ project = Project.new(attributes)
+ project.name = @generated_project_identifier if project.name.blank?
+ project.identifier = @generated_project_identifier if project.identifier.blank?
+ yield project if block_given?
+ project.save!
+ project
+ end
+
+ def Tracker.generate!(attributes={})
+ @generated_tracker_name ||= 'Tracker 0'
+ @generated_tracker_name.succ!
+ tracker = Tracker.new(attributes)
+ tracker.name = @generated_tracker_name if tracker.name.blank?
+ yield tracker if block_given?
+ tracker.save!
+ tracker
+ end
+
+ def Role.generate!(attributes={})
+ @generated_role_name ||= 'Role 0'
+ @generated_role_name.succ!
+ role = Role.new(attributes)
+ role.name = @generated_role_name if role.name.blank?
+ yield role if block_given?
+ role.save!
+ role
+ end
+
+ def Issue.generate!(attributes={})
+ issue = Issue.new(attributes)
+ issue.subject = 'Generated' if issue.subject.blank?
+ issue.author ||= User.find(2)
+ yield issue if block_given?
+ issue.save!
+ issue
+ end
+
+ def Version.generate!(attributes={})
+ @generated_version_name ||= 'Version 0'
+ @generated_version_name.succ!
+ version = Version.new(attributes)
+ version.name = @generated_version_name if version.name.blank?
+ yield version if block_given?
+ version.save!
+ version
+ end
+
+ def AuthSource.generate!(attributes={})
+ @generated_auth_source_name ||= 'Auth 0'
+ @generated_auth_source_name.succ!
+ source = AuthSource.new(attributes)
+ source.name = @generated_auth_source_name if source.name.blank?
+ yield source if block_given?
+ source.save!
+ source
+ end
+
+ # Generate the default Query
+ def Query.generate_default!(attributes={})
+ query = Query.new(attributes)
+ query.name = '_' if query.name.blank?
+ query.save!
+ query
+ end
+
+ # Generate an issue for a project, using it's trackers
+ def Issue.generate_for_project!(project, attributes={})
+ issue = Issue.new(attributes) do |issue|
+ issue.project = project
+ issue.tracker = project.trackers.first unless project.trackers.empty?
+ issue.subject = 'Generated' if issue.subject.blank?
+ issue.author ||= User.find(2)
+ yield issue if block_given?
+ end
+ issue.save!
+ issue
+ end
+end
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