Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions lib/rails/convert_rails_test_request_methods_4_2_to_5_0.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
next if argument_node.to_source == 'nil'

if argument_node.type == :hash
new_value = argument_node.children.reject { |pair_node| pair_node.key.to_value == :format }
.map(&:to_source).join(', ')
new_value =
argument_node.children.reject { |pair_node| pair_node.key.to_value == :format }.map(&:to_source).join(', ')
"#{key}: #{add_curly_brackets_if_necessary(new_value)}"
else
"#{key}: #{argument_node.to_source}"
Expand Down Expand Up @@ -89,8 +89,7 @@
%w[get post put patch delete].each do |message|
with_node type: 'send', message: message do
next unless node.arguments.size > 1
if node.arguments[1].type == :hash &&
(node.arguments[1].key?(:params) || node.arguments[1].key?(:headers))
if node.arguments[1].type == :hash && (node.arguments[1].key?(:params) || node.arguments[1].key?(:headers))
next
end

Expand Down
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
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def test_xhr
end
end
EOS

let(:test_rewritten_content) { <<~EOS }
class PostsControllerTest < ActionController::TestCase
def test_show
Expand Down