]> source.dussan.org Git - redmine.git/commitdiff
Use a single hash as argument.
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Thu, 1 Sep 2016 17:39:02 +0000 (17:39 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Thu, 1 Sep 2016 17:39:02 +0000 (17:39 +0000)
git-svn-id: http://svn.redmine.org/redmine/trunk@15805 e93f8b46-1217-0410-a6f0-8f06a7374b81

test/functional/issues_controller_test.rb
test/object_helpers.rb

index 45605bd9e95d12ad8f99a91e875c5434b567f5af..61c03af6083a220511f220b8fbd1eda6837fb91c 100644 (file)
@@ -2092,7 +2092,7 @@ class IssuesControllerTest < Redmine::ControllerTest
     @request.session[:user_id] = 2
     tracker = Tracker.find(2)
     tracker.update! :default_status_id => 2
-    tracker.generate_transitions! 2, 1, :clear => true
+    tracker.generate_transitions! 2 => 1, :clear => true
 
     post :new, :project_id => 1,
                :issue => {:tracker_id => 2,
index 46673638af29a66efbd449cb6e215c6818fc001c..3928dd5cc873ecb181bd99f9afd066aaec439d51 100644 (file)
@@ -243,21 +243,21 @@ module ObjectHelpers
 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]
+  def generate_transitions!(arg)
+    if arg.delete(: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
-      )
+    role_id = arg.delete(:role_id) || 1
+
+    arg.each do |old_status_id, new_status_ids|
+      Array.wrap(new_status_ids).each do |new_status_id|
+        WorkflowTransition.create!(
+          :tracker => self,
+          :role_id => role_id,
+          :old_status_id => old_status_id,
+          :new_status_id => new_status_id
+        )
+      end
     end
   end
 end