@@ -0,0 +1,9 | |||||
|
1 | class Query < ActiveRecord::Base | |||
|
2 | generator_for :name, :method => :next_name | |||
|
3 | ||||
|
4 | def self.next_name | |||
|
5 | @last_name ||= 'Query 0' | |||
|
6 | @last_name.succ! | |||
|
7 | @last_name | |||
|
8 | end | |||
|
9 | end |
@@ -1,7 +1,9 | |||||
1 | class Project < ActiveRecord::Base |
|
1 | class Project < ActiveRecord::Base | |
2 | generator_for :name, :method => :next_name |
|
2 | generator_for :name, :method => :next_name | |
3 | generator_for :identifier, :method => :next_identifier_from_object_daddy |
|
3 | generator_for :identifier, :method => :next_identifier_from_object_daddy | |
4 |
|
4 | generator_for :enabled_modules, :method => :all_modules | ||
|
5 | generator_for :trackers, :method => :next_tracker | |||
|
6 | ||||
5 | def self.next_name |
|
7 | def self.next_name | |
6 | @last_name ||= 'Project 0' |
|
8 | @last_name ||= 'Project 0' | |
7 | @last_name.succ! |
|
9 | @last_name.succ! | |
@@ -14,4 +16,16 class Project < ActiveRecord::Base | |||||
14 | @last_identifier.succ! |
|
16 | @last_identifier.succ! | |
15 | @last_identifier |
|
17 | @last_identifier | |
16 | end |
|
18 | end | |
|
19 | ||||
|
20 | def self.all_modules | |||
|
21 | returning [] do |modules| | |||
|
22 | Redmine::AccessControl.available_project_modules.each do |name| | |||
|
23 | modules << EnabledModule.new(:name => name.to_s) | |||
|
24 | end | |||
|
25 | end | |||
|
26 | end | |||
|
27 | ||||
|
28 | def self.next_tracker | |||
|
29 | [Tracker.generate!] | |||
|
30 | end | |||
17 | end |
|
31 | end |
@@ -34,6 +34,24 def User.generate_with_protected!(attributes={}) | |||||
34 | user |
|
34 | user | |
35 | end |
|
35 | end | |
36 |
|
36 | |||
|
37 | # Generate the default Query | |||
|
38 | def Query.generate_default!(attributes={}) | |||
|
39 | query = Query.spawn(attributes) | |||
|
40 | query.name ||= '_' | |||
|
41 | query.save! | |||
|
42 | query | |||
|
43 | end | |||
|
44 | ||||
|
45 | # Generate an issue for a project, using it's trackers | |||
|
46 | def Issue.generate_for_project!(project, attributes={}) | |||
|
47 | issue = Issue.spawn(attributes) do |issue| | |||
|
48 | issue.project = project | |||
|
49 | end | |||
|
50 | issue.tracker = project.trackers.first unless project.trackers.empty? | |||
|
51 | issue.save! | |||
|
52 | issue | |||
|
53 | end | |||
|
54 | ||||
37 | class ActiveSupport::TestCase |
|
55 | class ActiveSupport::TestCase | |
38 | # Transactional fixtures accelerate your tests by wrapping each test method |
|
56 | # Transactional fixtures accelerate your tests by wrapping each test method | |
39 | # in a transaction that's rolled back on completion. This ensures that the |
|
57 | # in a transaction that's rolled back on completion. This ensures that the |
General Comments 0
You need to be logged in to leave comments.
Login now