summaryrefslogtreecommitdiffstats
path: root/test/object_helpers.rb
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2014-11-02 19:45:14 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2014-11-02 19:45:14 +0000
commitdfc594c33702a123674dcae1d6b4bfe3a2f32fd3 (patch)
tree42f8653451b35f54db68bf914e1d963bfaf13418 /test/object_helpers.rb
parent32b79b6fd4e3a523ee393d7a3e2bb60dbeed77c3 (diff)
downloadredmine-dfc594c33702a123674dcae1d6b4bfe3a2f32fd3.tar.gz
redmine-dfc594c33702a123674dcae1d6b4bfe3a2f32fd3.zip
Default status per tracker (#5991).
git-svn-id: http://svn.redmine.org/redmine/trunk@13535 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/object_helpers.rb')
-rw-r--r--test/object_helpers.rb33
1 files changed, 32 insertions, 1 deletions
diff --git a/test/object_helpers.rb b/test/object_helpers.rb
index f3c671bf5..ca58638d9 100644
--- a/test/object_helpers.rb
+++ b/test/object_helpers.rb
@@ -45,11 +45,22 @@ module ObjectHelpers
project
end
+ def IssueStatus.generate!(attributes={})
+ @generated_status_name ||= 'Status 0'
+ @generated_status_name.succ!
+ status = IssueStatus.new(attributes)
+ status.name = @generated_status_name.dup if status.name.blank?
+ yield status if block_given?
+ status.save!
+ status
+ end
+
def Tracker.generate!(attributes={})
@generated_tracker_name ||= 'Tracker 0'
@generated_tracker_name.succ!
tracker = Tracker.new(attributes)
tracker.name = @generated_tracker_name.dup if tracker.name.blank?
+ tracker.default_status ||= IssueStatus.order('position').first || IssueStatus.generate!
yield tracker if block_given?
tracker.save!
tracker
@@ -188,6 +199,27 @@ module ObjectHelpers
end
end
+module TrackerObjectHelpers
+ def generate_transitions!(*args)
+ options = args.last.is_a?(Hash) ? args.pop : {}
+ if args.size == 1
+ args << args.first
+ end
+ if options[:clear]
+ WorkflowTransition.where(:tracker_id => id).delete_all
+ end
+ args.each_cons(2) do |old_status_id, new_status_id|
+ WorkflowTransition.create!(
+ :tracker => self,
+ :role_id => (options[:role_id] || 1),
+ :old_status_id => old_status_id,
+ :new_status_id => new_status_id
+ )
+ end
+ end
+end
+Tracker.send :include, TrackerObjectHelpers
+
module IssueObjectHelpers
def close!
self.status = IssueStatus.where(:is_closed => true).first
@@ -198,5 +230,4 @@ module IssueObjectHelpers
Issue.generate!(attributes.merge(:parent_issue_id => self.id))
end
end
-
Issue.send :include, IssueObjectHelpers