From: Jean-Philippe Lang Date: Thu, 1 Sep 2016 17:39:02 +0000 (+0000) Subject: Use a single hash as argument. X-Git-Tag: 3.4.0~704 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=ddc575564744cbc65600a0aaf92f55ec65570e83;p=redmine.git Use a single hash as argument. git-svn-id: http://svn.redmine.org/redmine/trunk@15805 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- diff --git a/test/functional/issues_controller_test.rb b/test/functional/issues_controller_test.rb index 45605bd9e..61c03af60 100644 --- a/test/functional/issues_controller_test.rb +++ b/test/functional/issues_controller_test.rb @@ -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, diff --git a/test/object_helpers.rb b/test/object_helpers.rb index 46673638a..3928dd5cc 100644 --- a/test/object_helpers.rb +++ b/test/object_helpers.rb @@ -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