From 34d9053819ab82ddf62f7fe84748fe5a7aebbb50 Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Sun, 7 Jun 2020 19:37:53 -0300 Subject: [PATCH] Remove unnecessary monkey-patch of test helpers with Rails 5+ 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.) --- test/support/http_method_compatibility.rb | 36 +++++++---------------- 1 file changed, 10 insertions(+), 26 deletions(-) diff --git a/test/support/http_method_compatibility.rb b/test/support/http_method_compatibility.rb index de207087..f901ad85 100644 --- a/test/support/http_method_compatibility.rb +++ b/test/support/http_method_compatibility.rb @@ -5,19 +5,11 @@ module Devise # %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 @@ -30,19 +22,11 @@ module Devise # %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