Skip to content

Commit

Permalink
Remove unnecessary monkey-patch of test helpers with Rails 5+
Browse files Browse the repository at this point in the history
This is warning on Ruby 2.7, and seems unnecessary since Rails 5+
adopted kwargs approach. We still need to handle the difference for
Rails < 5 for now, while we support it (which I would like to remove
soon.)
  • Loading branch information
carlosantoniodasilva committed Jun 7, 2020
1 parent 94be5fb commit 34d9053
Showing 1 changed file with 10 additions and 26 deletions.
36 changes: 10 additions & 26 deletions test/support/http_method_compatibility.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,11 @@ class IntegrationTest < ActionDispatch::IntegrationTest
# %w( get post patch put head delete xml_http_request
# xhr get_via_redirect post_via_redirect
# ).each do |method|
%w( get post put ).each do |method|
if Devise::Test.rails5_and_up?
define_method(method) do |url, options={}|
if options.empty?
super url
else
super url, options
end
end
else
define_method(method) do |url, options={}|
if options[:xhr]==true
xml_http_request __method__, url, options[:params] || {}, options[:headers]
unless Devise::Test.rails5_and_up?
%w( get post put ).each do |method|
define_method(method) do |url, options = {}|
if options[:xhr] == true
xml_http_request __method__, url, options[:params] || {}, options[:headers]
else
super url, options[:params] || {}, options[:headers]
end
Expand All @@ -30,19 +22,11 @@ class ControllerTestCase < ActionController::TestCase
# %w( get post patch put head delete xml_http_request
# xhr get_via_redirect post_via_redirect
# ).each do |method|
%w( get post put ).each do |method|
if Devise::Test.rails5_and_up?
define_method(method) do |action, options={}|
if options.empty?
super action
else
super action, options
end
end
else
define_method(method) do |action, options={}|
if options[:xhr]==true
xml_http_request __method__, action, options[:params] || {}, options[:headers]
unless Devise::Test.rails5_and_up?
%w( get post put ).each do |method|
define_method(method) do |action, options = {}|
if options[:xhr] == true
xml_http_request __method__, action, options[:params] || {}, options[:headers]
else
super action, options[:params] || {}, options[:headers]
end
Expand Down

0 comments on commit 34d9053

Please sign in to comment.