]> source.dussan.org Git - redmine.git/commitdiff
Renamed object_daddy_helper and removed exemplars.
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 22 Apr 2012 11:58:05 +0000 (11:58 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 22 Apr 2012 11:58:05 +0000 (11:58 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@9470 e93f8b46-1217-0410-a6f0-8f06a7374b81

40 files changed:
test/exemplars/attachment_exemplar.rb [deleted file]
test/exemplars/auth_source_exemplar.rb [deleted file]
test/exemplars/board_exemplar.rb [deleted file]
test/exemplars/change_exemplar.rb [deleted file]
test/exemplars/changeset_exemplar.rb [deleted file]
test/exemplars/comment_exemplar.rb [deleted file]
test/exemplars/custom_field_exemplar.rb [deleted file]
test/exemplars/custom_value_exemplar.rb [deleted file]
test/exemplars/document_category_exemplar.rb [deleted file]
test/exemplars/document_exemplar.rb [deleted file]
test/exemplars/enabled_module_exemplar.rb [deleted file]
test/exemplars/enumeration_exemplar.rb [deleted file]
test/exemplars/group_exemplar.rb [deleted file]
test/exemplars/issue_category_exemplar.rb [deleted file]
test/exemplars/issue_exemplar.rb [deleted file]
test/exemplars/issue_priority_exemplar.rb [deleted file]
test/exemplars/issue_status_exemplar.rb [deleted file]
test/exemplars/journal_exemplar.rb [deleted file]
test/exemplars/member_exemplar.rb [deleted file]
test/exemplars/member_role_exemplar.rb [deleted file]
test/exemplars/message_exemplar.rb [deleted file]
test/exemplars/news_exemplar.rb [deleted file]
test/exemplars/project_exemplar.rb [deleted file]
test/exemplars/query_exemplar.rb [deleted file]
test/exemplars/repository_exemplar.rb [deleted file]
test/exemplars/role_exemplar.rb [deleted file]
test/exemplars/subversion_repository_exemplar.rb [deleted file]
test/exemplars/time_entry_activity.rb [deleted file]
test/exemplars/time_entry_exemplar.rb [deleted file]
test/exemplars/tracker_exemplar.rb [deleted file]
test/exemplars/user_exemplar.rb [deleted file]
test/exemplars/version_exemplar.rb [deleted file]
test/exemplars/watcher_exemplar.rb [deleted file]
test/exemplars/wiki_content_exemplar.rb [deleted file]
test/exemplars/wiki_exemplar.rb [deleted file]
test/exemplars/wiki_page_exemplar.rb [deleted file]
test/exemplars/wiki_redirect_exemplar.rb [deleted file]
test/object_daddy_helpers.rb [deleted file]
test/object_helpers.rb [new file with mode: 0644]
test/test_helper.rb

diff --git a/test/exemplars/attachment_exemplar.rb b/test/exemplars/attachment_exemplar.rb
deleted file mode 100644 (file)
index 4baaf53..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-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
diff --git a/test/exemplars/auth_source_exemplar.rb b/test/exemplars/auth_source_exemplar.rb
deleted file mode 100644 (file)
index 3976aeb..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-class AuthSource < ActiveRecord::Base
-  generator_for :name, :start => 'Auth0'
-
-end
diff --git a/test/exemplars/board_exemplar.rb b/test/exemplars/board_exemplar.rb
deleted file mode 100644 (file)
index eb8643d..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-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
diff --git a/test/exemplars/change_exemplar.rb b/test/exemplars/change_exemplar.rb
deleted file mode 100644 (file)
index 07f30ec..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-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
diff --git a/test/exemplars/changeset_exemplar.rb b/test/exemplars/changeset_exemplar.rb
deleted file mode 100644 (file)
index 62d6ee3..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-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
diff --git a/test/exemplars/comment_exemplar.rb b/test/exemplars/comment_exemplar.rb
deleted file mode 100644 (file)
index 036e827..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-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
diff --git a/test/exemplars/custom_field_exemplar.rb b/test/exemplars/custom_field_exemplar.rb
deleted file mode 100644 (file)
index 81e7788..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-class CustomField < ActiveRecord::Base
-  generator_for :name, :start => 'CustomField0'
-  generator_for :field_format => 'string'
-
-end
diff --git a/test/exemplars/custom_value_exemplar.rb b/test/exemplars/custom_value_exemplar.rb
deleted file mode 100644 (file)
index aeb5412..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-class CustomValue < ActiveRecord::Base
-  generator_for :custom_field, :method => :generate_custom_field
-
-  def self.generate_custom_field
-    CustomField.generate!
-  end
-end
diff --git a/test/exemplars/document_category_exemplar.rb b/test/exemplars/document_category_exemplar.rb
deleted file mode 100644 (file)
index 758b6d4..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-class DocumentCategory < Enumeration
-  generator_for :name, :start => 'DocumentCategory0'
-  generator_for :type => 'DocumentCategory'
-
-end
diff --git a/test/exemplars/document_exemplar.rb b/test/exemplars/document_exemplar.rb
deleted file mode 100644 (file)
index 1d8e710..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-class Document < ActiveRecord::Base
-  generator_for :title, :start => 'Document001'
-
-end
diff --git a/test/exemplars/enabled_module_exemplar.rb b/test/exemplars/enabled_module_exemplar.rb
deleted file mode 100644 (file)
index 60f0631..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-class EnabledModule < ActiveRecord::Base
-  generator_for :name, :start => 'module_001'
-
-end
diff --git a/test/exemplars/enumeration_exemplar.rb b/test/exemplars/enumeration_exemplar.rb
deleted file mode 100644 (file)
index 29e4f45..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-class Enumeration < ActiveRecord::Base
-  generator_for :name, :start => 'Enumeration0'
-  generator_for :type => 'TimeEntryActivity'
-
-end
diff --git a/test/exemplars/group_exemplar.rb b/test/exemplars/group_exemplar.rb
deleted file mode 100644 (file)
index a6851b4..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-class Group < Principal
-  generator_for :lastname, :start => 'Group'
-
-end
diff --git a/test/exemplars/issue_category_exemplar.rb b/test/exemplars/issue_category_exemplar.rb
deleted file mode 100644 (file)
index 246eafc..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-class IssueCategory < ActiveRecord::Base
-  generator_for :name, :start => 'Category 0001'
-
-end
diff --git a/test/exemplars/issue_exemplar.rb b/test/exemplars/issue_exemplar.rb
deleted file mode 100644 (file)
index 17868e6..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-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
diff --git a/test/exemplars/issue_priority_exemplar.rb b/test/exemplars/issue_priority_exemplar.rb
deleted file mode 100644 (file)
index 5059da5..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-class IssuePriority < Enumeration
-  generator_for :name, :start => 'IssuePriority0'
-  generator_for :type => 'IssuePriority'
-
-end
diff --git a/test/exemplars/issue_status_exemplar.rb b/test/exemplars/issue_status_exemplar.rb
deleted file mode 100644 (file)
index 0576568..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-class IssueStatus < ActiveRecord::Base
-  generator_for :name, :start => 'Status 0'
-
-end
diff --git a/test/exemplars/journal_exemplar.rb b/test/exemplars/journal_exemplar.rb
deleted file mode 100644 (file)
index dbb66f2..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-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
diff --git a/test/exemplars/member_exemplar.rb b/test/exemplars/member_exemplar.rb
deleted file mode 100644 (file)
index ecb09bb..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-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
diff --git a/test/exemplars/member_role_exemplar.rb b/test/exemplars/member_role_exemplar.rb
deleted file mode 100644 (file)
index 0e1e6e7..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-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
diff --git a/test/exemplars/message_exemplar.rb b/test/exemplars/message_exemplar.rb
deleted file mode 100644 (file)
index 67c5b67..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-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
diff --git a/test/exemplars/news_exemplar.rb b/test/exemplars/news_exemplar.rb
deleted file mode 100644 (file)
index d58a292..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-class News < ActiveRecord::Base
-  generator_for :title, :start => 'A New Item'
-  generator_for :description, :start => 'Some content here'
-
-end
diff --git a/test/exemplars/project_exemplar.rb b/test/exemplars/project_exemplar.rb
deleted file mode 100644 (file)
index ceda2be..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-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
diff --git a/test/exemplars/query_exemplar.rb b/test/exemplars/query_exemplar.rb
deleted file mode 100644 (file)
index 2b0847c..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-class Query < ActiveRecord::Base
-  generator_for :name, :start => 'Query 0'
-
-end
diff --git a/test/exemplars/repository_exemplar.rb b/test/exemplars/repository_exemplar.rb
deleted file mode 100644 (file)
index 961bee7..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-class Repository < ActiveRecord::Base
-  generator_for :type => 'Subversion'
-  generator_for :url, :start => 'file:///test/svn'
-  generator_for :identifier, :start => 'repo1'
-end
diff --git a/test/exemplars/role_exemplar.rb b/test/exemplars/role_exemplar.rb
deleted file mode 100644 (file)
index 00bad92..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-class Role < ActiveRecord::Base
-  generator_for :name, :start => 'Role0'
-
-end
diff --git a/test/exemplars/subversion_repository_exemplar.rb b/test/exemplars/subversion_repository_exemplar.rb
deleted file mode 100644 (file)
index 93c9fd1..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-class Repository::Subversion < Repository
-  generator_for :type, :method => 'Subversion'
-  generator_for :url, :start => 'file:///test/svn'
-
-end
diff --git a/test/exemplars/time_entry_activity.rb b/test/exemplars/time_entry_activity.rb
deleted file mode 100644 (file)
index e5e318d..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-class TimeEntryActivity < Enumeration
-  generator_for :name, :start => 'TimeEntryActivity0'
-  generator_for :type => 'TimeEntryActivity'
-
-end
diff --git a/test/exemplars/time_entry_exemplar.rb b/test/exemplars/time_entry_exemplar.rb
deleted file mode 100644 (file)
index c8f2e20..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-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
diff --git a/test/exemplars/tracker_exemplar.rb b/test/exemplars/tracker_exemplar.rb
deleted file mode 100644 (file)
index 0aa0d3b..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-class Tracker < ActiveRecord::Base
-  generator_for :name, :start => 'Tracker 0'
-
-end
diff --git a/test/exemplars/user_exemplar.rb b/test/exemplars/user_exemplar.rb
deleted file mode 100644 (file)
index 7aee145..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-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
diff --git a/test/exemplars/version_exemplar.rb b/test/exemplars/version_exemplar.rb
deleted file mode 100644 (file)
index 14a9dd1..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-class Version < ActiveRecord::Base
-  generator_for :name, :start => 'Version 1.0.0'
-  generator_for :status => 'open'
-
-end
diff --git a/test/exemplars/watcher_exemplar.rb b/test/exemplars/watcher_exemplar.rb
deleted file mode 100644 (file)
index 4d6c266..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-class Watcher < ActiveRecord::Base
-  generator_for :user, :method => :generate_user
-
-  def self.generate_user
-    User.generate_with_protected!
-  end
-end
diff --git a/test/exemplars/wiki_content_exemplar.rb b/test/exemplars/wiki_content_exemplar.rb
deleted file mode 100644 (file)
index 79465b0..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-class WikiContent < ActiveRecord::Base
-  generator_for :text => 'Some content'
-  generator_for :page, :method => :generate_page
-
-  def self.generate_page
-    WikiPage.generate!
-  end
-end
diff --git a/test/exemplars/wiki_exemplar.rb b/test/exemplars/wiki_exemplar.rb
deleted file mode 100644 (file)
index 65b93a2..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-class Wiki < ActiveRecord::Base
-  generator_for :start_page => 'Start'
-  generator_for :project, :method => :generate_project
-
-  def self.generate_project
-    Project.generate!
-  end
-end
diff --git a/test/exemplars/wiki_page_exemplar.rb b/test/exemplars/wiki_page_exemplar.rb
deleted file mode 100644 (file)
index 8db9a0e..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-class WikiPage < ActiveRecord::Base
-  generator_for :title, :start => 'AWikiPage'
-  generator_for :wiki, :method => :generate_wiki
-
-  def self.generate_wiki
-    Wiki.generate!
-  end
-end
diff --git a/test/exemplars/wiki_redirect_exemplar.rb b/test/exemplars/wiki_redirect_exemplar.rb
deleted file mode 100644 (file)
index cedb5bd..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-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
diff --git a/test/object_daddy_helpers.rb b/test/object_daddy_helpers.rb
deleted file mode 100644 (file)
index 9a5c797..0000000
+++ /dev/null
@@ -1,124 +0,0 @@
-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
diff --git a/test/object_helpers.rb b/test/object_helpers.rb
new file mode 100644 (file)
index 0000000..3cd5e5c
--- /dev/null
@@ -0,0 +1,124 @@
+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
index 075acc5ddea738fd17dd634aff003ccf37463550..759aaf43886c9f4e21ba1830cf425e6f5daa52ab 100644 (file)
@@ -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