Bye PathChecker
This commit is contained in:
parent
7739c495e7
commit
1a41fff009
|
@ -10,7 +10,6 @@ module Devise
|
|||
autoload :FailureApp, 'devise/failure_app'
|
||||
autoload :OmniAuth, 'devise/omniauth'
|
||||
autoload :ParamFilter, 'devise/param_filter'
|
||||
autoload :PathChecker, 'devise/path_checker'
|
||||
autoload :Schema, 'devise/schema'
|
||||
autoload :TestHelpers, 'devise/test_helpers'
|
||||
|
||||
|
|
|
@ -1,23 +0,0 @@
|
|||
module Devise
|
||||
class PathChecker
|
||||
include Rails.application.routes.url_helpers
|
||||
|
||||
def self.default_url_options(*args)
|
||||
if defined?(ApplicationController)
|
||||
ApplicationController.default_url_options(*args)
|
||||
else
|
||||
{}
|
||||
end
|
||||
end
|
||||
|
||||
def initialize(env, scope)
|
||||
@current_path = "/#{env["SCRIPT_NAME"]}/#{env["PATH_INFO"]}".squeeze("/")
|
||||
@scope = scope
|
||||
end
|
||||
|
||||
def signing_out?
|
||||
route = "destroy_#{@scope}_session_path"
|
||||
respond_to?(route) && @current_path == send(route)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,21 +0,0 @@
|
|||
require 'test_helper'
|
||||
|
||||
class PathCheckerTest < ActiveSupport::TestCase
|
||||
test 'check if sign out path matches' do
|
||||
path_checker = Devise::PathChecker.new({"PATH_INFO" => "/users/sign_out"}, :user)
|
||||
assert path_checker.signing_out?
|
||||
|
||||
path_checker = Devise::PathChecker.new({"PATH_INFO" => "/users/sign_in"}, :user)
|
||||
assert_not path_checker.signing_out?
|
||||
end
|
||||
|
||||
test 'considers script name' do
|
||||
path_checker = Devise::PathChecker.new({"SCRIPT_NAME" => "/users", "PATH_INFO" => "/sign_out"}, :user)
|
||||
assert path_checker.signing_out?
|
||||
end
|
||||
|
||||
test 'ignores invalid routes' do
|
||||
path_checker = Devise::PathChecker.new({"PATH_INFO" => "/users/sign_in"}, :omg)
|
||||
assert_not path_checker.signing_out?
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue