summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--test/exemplars/project_exemplar.rb16
-rw-r--r--test/exemplars/query_exemplar.rb9
-rw-r--r--test/test_helper.rb18
3 files changed, 42 insertions, 1 deletions
diff --git a/test/exemplars/project_exemplar.rb b/test/exemplars/project_exemplar.rb
index a0edd1fde..f1667b7cf 100644
--- a/test/exemplars/project_exemplar.rb
+++ b/test/exemplars/project_exemplar.rb
@@ -1,7 +1,9 @@
class Project < ActiveRecord::Base
generator_for :name, :method => :next_name
generator_for :identifier, :method => :next_identifier_from_object_daddy
-
+ generator_for :enabled_modules, :method => :all_modules
+ generator_for :trackers, :method => :next_tracker
+
def self.next_name
@last_name ||= 'Project 0'
@last_name.succ!
@@ -14,4 +16,16 @@ class Project < ActiveRecord::Base
@last_identifier.succ!
@last_identifier
end
+
+ def self.all_modules
+ returning [] 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
new file mode 100644
index 000000000..db32e938a
--- /dev/null
+++ b/test/exemplars/query_exemplar.rb
@@ -0,0 +1,9 @@
+class Query < ActiveRecord::Base
+ generator_for :name, :method => :next_name
+
+ def self.next_name
+ @last_name ||= 'Query 0'
+ @last_name.succ!
+ @last_name
+ end
+end
diff --git a/test/test_helper.rb b/test/test_helper.rb
index 37f8bfd00..3a3b12424 100644
--- a/test/test_helper.rb
+++ b/test/test_helper.rb
@@ -34,6 +34,24 @@ def User.generate_with_protected!(attributes={})
user
end
+# Generate the default Query
+def Query.generate_default!(attributes={})
+ query = Query.spawn(attributes)
+ query.name ||= '_'
+ query.save!
+ query
+end
+
+# Generate an issue for a project, using it's trackers
+def Issue.generate_for_project!(project, attributes={})
+ issue = Issue.spawn(attributes) do |issue|
+ issue.project = project
+ end
+ issue.tracker = project.trackers.first unless project.trackers.empty?
+ issue.save!
+ issue
+end
+
class ActiveSupport::TestCase
# Transactional fixtures accelerate your tests by wrapping each test method
# in a transaction that's rolled back on completion. This ensures that the