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