From 49ac09b025f635ae6684d217332cc5f85e435cf7 Mon Sep 17 00:00:00 2001 From: Awesome Code Date: Mon, 22 Mar 2021 14:41:13 +0000 Subject: [PATCH] Auto corrected by following Format Ruby Code --- lib/rails/convert_routes_2_3_to_3_0.rb | 30 +++++++++---------- .../convert_rails_test_xhr_4_2_to_5_0_spec.rb | 1 + 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/lib/rails/convert_routes_2_3_to_3_0.rb b/lib/rails/convert_routes_2_3_to_3_0.rb index 24a2ce90..23548441 100644 --- a/lib/rails/convert_routes_2_3_to_3_0.rb +++ b/lib/rails/convert_routes_2_3_to_3_0.rb @@ -327,26 +327,26 @@ url = node.arguments.first.to_value hash_node = node.arguments.last if hash_node.type == :hash && hash_node.key?(:controller) - if hash_node.key?(:action) || url !~ /:action/ - controller_action_name = - if hash_node.key?(:action) - extract_controller_action_name(hash_node) - else - "#{hash_node.hash_value(:controller).to_value}#index" - end - method = extract_method(hash_node) - subdomain_node = extract_subdomain_node(hash_node) - other_options_code = reject_keys_from_hash(hash_node, :controller, :action, :method, :conditions) - other_options_code += ":constraints => {:subdomain => #{subdomain_node.to_source}}" if subdomain_node - if other_options_code.length > 0 - replace_with "#{method} {{arguments.first}}, :to => \"#{controller_action_name}\", #{other_options_code}, :as => \"#{message}\"" + if hash_node.key?(:action) || url !~ /:action/ + controller_action_name = + if hash_node.key?(:action) + extract_controller_action_name(hash_node) else - replace_with "#{method} {{arguments.first}}, :to => \"#{controller_action_name}\", :as => \"#{message}\"" + "#{hash_node.hash_value(:controller).to_value}#index" end + method = extract_method(hash_node) + subdomain_node = extract_subdomain_node(hash_node) + other_options_code = reject_keys_from_hash(hash_node, :controller, :action, :method, :conditions) + other_options_code += ":constraints => {:subdomain => #{subdomain_node.to_source}}" if subdomain_node + if other_options_code.length > 0 + replace_with "#{method} {{arguments.first}}, :to => \"#{controller_action_name}\", #{other_options_code}, :as => \"#{message}\"" else - replace_with 'match {{arguments}}' + replace_with "#{method} {{arguments.first}}, :to => \"#{controller_action_name}\", :as => \"#{message}\"" end + else + replace_with 'match {{arguments}}' end + end end end end diff --git a/spec/rails/convert_rails_test_xhr_4_2_to_5_0_spec.rb b/spec/rails/convert_rails_test_xhr_4_2_to_5_0_spec.rb index 0e04aca4..e640b1d0 100644 --- a/spec/rails/convert_rails_test_xhr_4_2_to_5_0_spec.rb +++ b/spec/rails/convert_rails_test_xhr_4_2_to_5_0_spec.rb @@ -16,6 +16,7 @@ class PostsControllerTest < ActionController::TestCase end end EOS + let(:test_rewritten_content) { <<~EOS } class PostsControllerTest < ActionController::TestCase context "on XHR GET to show" do