mirror of
https://github.com/heartcombo/devise.git
synced 2022-11-09 12:18:31 -05:00
Add tests for http_authenticatable_on_xhr option
This commit is contained in:
parent
bd0e2a3180
commit
b9df42c350
1 changed files with 14 additions and 0 deletions
|
@ -77,6 +77,20 @@ class FailureTest < ActiveSupport::TestCase
|
|||
assert_equal 'Basic realm="Application"', @response.second["WWW-Authenticate"]
|
||||
end
|
||||
|
||||
test 'dont return WWW-authenticate on ajax call if http_authenticatable_on_xhr false' do
|
||||
swap Devise, :http_authenticatable_on_xhr => false do
|
||||
call_failure('formats' => :html, 'HTTP_X_REQUESTED_WITH' => 'XMLHttpRequest')
|
||||
assert_nil @response.second['WWW-Authenticate']
|
||||
end
|
||||
end
|
||||
|
||||
test 'return WWW-authenticate on ajax call if http_authenticatable_on_xhr true' do
|
||||
swap Devise, :http_authenticatable_on_xhr => true do
|
||||
call_failure('formats' => :html, 'HTTP_X_REQUESTED_WITH' => 'XMLHttpRequest')
|
||||
assert_equal 'Basic realm="Application"', @response.second["WWW-Authenticate"]
|
||||
end
|
||||
end
|
||||
|
||||
test 'uses the proxy failure message as response body' do
|
||||
call_failure('formats' => :xml, 'warden' => OpenStruct.new(:message => :invalid))
|
||||
assert_match '<error>Invalid email or password.</error>', @response.third.body
|
||||
|
|
Loading…
Add table
Reference in a new issue