mirror of
https://github.com/heartcombo/devise.git
synced 2022-11-09 12:18:31 -05:00
PathChecker should not attempt to validate invalid routes, closes #1505
This commit is contained in:
parent
5eebf74f69
commit
fd85b25d29
2 changed files with 23 additions and 1 deletions
|
@ -12,7 +12,8 @@ module Devise
|
|||
end
|
||||
|
||||
def signing_out?
|
||||
@current_path == send("destroy_#{@scope}_session_path")
|
||||
route = "destroy_#{@scope}_session_path"
|
||||
respond_to?(route) && @current_path == send(route)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
21
test/path_checker_test.rb
Normal file
21
test/path_checker_test.rb
Normal file
|
@ -0,0 +1,21 @@
|
|||
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…
Add table
Reference in a new issue