mirror of
https://github.com/heartcombo/devise.git
synced 2022-11-09 12:18:31 -05:00
Add a test case to previous commit
This commit is contained in:
parent
ad0aed3ba5
commit
65ef2592f6
2 changed files with 12 additions and 3 deletions
|
@ -9,6 +9,7 @@
|
|||
* valid_for_authentication? must now return a boolean
|
||||
|
||||
* bug fix
|
||||
* Ensure the failure app still respects config.relative_url_root
|
||||
* `/users/sign_in` doesn't choke on protected attributes used to select sign in scope (by @Paymium)
|
||||
* `failed_attempts` is set to zero after any sign in (including via reset password) (by @rodrigoflores)
|
||||
* Added token expiration on timeout (by @antiarchitect)
|
||||
|
|
|
@ -29,20 +29,20 @@ class FailureTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
context 'When redirecting' do
|
||||
test 'return to the default redirect location' do
|
||||
test 'returns to the default redirect location' do
|
||||
call_failure
|
||||
assert_equal 302, @response.first
|
||||
assert_equal 'You need to sign in or sign up before continuing.', @request.flash[:alert]
|
||||
assert_equal 'http://test.host/users/sign_in', @response.second['Location']
|
||||
end
|
||||
|
||||
test 'return to the default redirect location for wildcard requests' do
|
||||
test 'returns to the default redirect location for wildcard requests' do
|
||||
call_failure 'action_dispatch.request.formats' => nil, 'HTTP_ACCEPT' => '*/*'
|
||||
assert_equal 302, @response.first
|
||||
assert_equal 'http://test.host/users/sign_in', @response.second['Location']
|
||||
end
|
||||
|
||||
test 'return to the root path if no session path is available' do
|
||||
test 'returns to the root path if no session path is available' do
|
||||
swap Devise, :router_name => :fake_app do
|
||||
call_failure :app => RootFailureApp
|
||||
assert_equal 302, @response.first
|
||||
|
@ -51,6 +51,14 @@ class FailureTest < ActiveSupport::TestCase
|
|||
end
|
||||
end
|
||||
|
||||
test 'returns to the default redirect location considering the relative url root' do
|
||||
swap Rails.application.config, :relative_url_root => "/sample" do
|
||||
call_failure
|
||||
assert_equal 302, @response.first
|
||||
assert_equal 'http://test.host/sample/users/sign_in', @response.second['Location']
|
||||
end
|
||||
end
|
||||
|
||||
test 'uses the proxy failure message as symbol' do
|
||||
call_failure('warden' => OpenStruct.new(:message => :invalid))
|
||||
assert_equal 'Invalid email or password.', @request.flash[:alert]
|
||||
|
|
Loading…
Reference in a new issue