Skip to content

Commit

Permalink
Merge 49ac09b into cdc7dbe
Browse files Browse the repository at this point in the history
  • Loading branch information
flyerhzm committed Mar 22, 2021
2 parents cdc7dbe + 49ac09b commit 91b6c6b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
30 changes: 15 additions & 15 deletions lib/rails/convert_routes_2_3_to_3_0.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions spec/rails/convert_rails_test_xhr_4_2_to_5_0_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 91b6c6b

Please sign in to comment.