Sha256: 7de3cd97f51a0091760c25c0ec2e9ae7cb3e4eaf8163c564798ccdc6c6bfb3eb

Contents?: true

Size: 1.56 KB

Versions: 5

Compression:

Stored size: 1.56 KB

Contents

# frozen_string_literal: true

module Devise
  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 Rails.version >= '5.0.0'
        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]
          else
            super url, options[:params] || {}, options[:headers]
          end
        end
      end
    end
  end

  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 Rails.version >= '5.0.0'
        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]
          else
            super action, options[:params] || {}, options[:headers]
          end
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
devise-4.5.0 test/support/http_method_compatibility.rb
devise-4.4.3 test/support/http_method_compatibility.rb
devise-4.4.2 test/support/http_method_compatibility.rb
devise-4.4.1 test/support/http_method_compatibility.rb
devise-4.4.0 test/support/http_method_compatibility.rb