mirror of
https://github.com/heartcombo/devise.git
synced 2022-11-09 12:18:31 -05:00
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.)
This commit is contained in:
parent
94be5fb6a1
commit
34d9053819
1 changed files with 10 additions and 26 deletions
|
@ -5,19 +5,11 @@ module Devise
|
||||||
# %w( get post patch put head delete xml_http_request
|
# %w( get post patch put head delete xml_http_request
|
||||||
# xhr get_via_redirect post_via_redirect
|
# xhr get_via_redirect post_via_redirect
|
||||||
# ).each do |method|
|
# ).each do |method|
|
||||||
%w( get post put ).each do |method|
|
unless Devise::Test.rails5_and_up?
|
||||||
if Devise::Test.rails5_and_up?
|
%w( get post put ).each do |method|
|
||||||
define_method(method) do |url, options={}|
|
define_method(method) do |url, options = {}|
|
||||||
if options.empty?
|
if options[:xhr] == true
|
||||||
super url
|
xml_http_request __method__, url, options[:params] || {}, options[:headers]
|
||||||
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]
|
|
||||||
else
|
else
|
||||||
super url, options[:params] || {}, options[:headers]
|
super url, options[:params] || {}, options[:headers]
|
||||||
end
|
end
|
||||||
|
@ -30,19 +22,11 @@ module Devise
|
||||||
# %w( get post patch put head delete xml_http_request
|
# %w( get post patch put head delete xml_http_request
|
||||||
# xhr get_via_redirect post_via_redirect
|
# xhr get_via_redirect post_via_redirect
|
||||||
# ).each do |method|
|
# ).each do |method|
|
||||||
%w( get post put ).each do |method|
|
unless Devise::Test.rails5_and_up?
|
||||||
if Devise::Test.rails5_and_up?
|
%w( get post put ).each do |method|
|
||||||
define_method(method) do |action, options={}|
|
define_method(method) do |action, options = {}|
|
||||||
if options.empty?
|
if options[:xhr] == true
|
||||||
super action
|
xml_http_request __method__, action, options[:params] || {}, options[:headers]
|
||||||
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]
|
|
||||||
else
|
else
|
||||||
super action, options[:params] || {}, options[:headers]
|
super action, options[:params] || {}, options[:headers]
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue