Skip to content

Commit

Permalink
Auto corrected by following Format Ruby Code
Browse files Browse the repository at this point in the history
  • Loading branch information
Awesome Code committed Mar 22, 2021
1 parent b0e82af commit c44306b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 19 deletions.
8 changes: 4 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,9 @@
next if argument_node.to_source == 'nil'

if argument_node.type == :hash
new_value = argument_node.children.reject { |pair_node| %i[format xhr].include?(pair_node.key.to_value) }
.map(&:to_source).join(', ')
new_value =
argument_node.children.reject { |pair_node| %i[format xhr].include?(pair_node.key.to_value) }.map(&:to_source)
.join(', ')
"#{key}: #{add_curly_brackets_if_necessary(new_value)}" if new_value.length > 0
else
"#{key}: #{argument_node.to_source}"
Expand Down Expand Up @@ -91,8 +92,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

0 comments on commit c44306b

Please sign in to comment.