test/integration/authenticatable_test.rb in devise-3.5.10 vs test/integration/authenticatable_test.rb in devise-4.0.0.rc1
- old
+ new
@@ -1,8 +1,8 @@
require 'test_helper'
-class AuthenticationSanityTest < ActionDispatch::IntegrationTest
+class AuthenticationSanityTest < Devise::IntegrationTest
test 'home should be accessible without sign in' do
visit '/'
assert_response :success
assert_template 'home/index'
end
@@ -132,11 +132,11 @@
assert_equal "Oops, not found", response.body
assert_equal 404, response.status
end
end
-class AuthenticationRoutesRestrictions < ActionDispatch::IntegrationTest
+class AuthenticationRoutesRestrictions < Devise::IntegrationTest
test 'not signed in should not be able to access private route (authenticate denied)' do
get private_path
assert_redirected_to new_admin_session_path
assert_not warden.authenticated?(:admin)
end
@@ -252,11 +252,11 @@
assert_template 'home/join'
assert_contain 'Join'
end
end
-class AuthenticationRedirectTest < ActionDispatch::IntegrationTest
+class AuthenticationRedirectTest < Devise::IntegrationTest
test 'redirect from warden shows sign in or sign up message' do
get admins_path
warden_path = new_admin_session_path
assert_redirected_to warden_path
@@ -298,11 +298,11 @@
assert_current_url '/users'
assert_nil session[:"user_return_to"]
end
test 'xml http requests does not store urls for redirect' do
- get users_path, {}, 'HTTP_X_REQUESTED_WITH' => 'XMLHttpRequest'
+ get users_path, headers: { 'HTTP_X_REQUESTED_WITH' => 'XMLHttpRequest' }
assert_equal 401, response.status
assert_nil session[:"user_return_to"]
end
test 'redirect to configured home path for a given scope after sign in' do
@@ -315,11 +315,11 @@
visit new_user_session_path
assert_equal flash[:alert], I18n.t("devise.failure.already_authenticated")
end
end
-class AuthenticationSessionTest < ActionDispatch::IntegrationTest
+class AuthenticationSessionTest < Devise::IntegrationTest
test 'destroyed account is signed out' do
sign_in_as_user
get '/users'
User.destroy_all
@@ -388,11 +388,11 @@
sign_in_as_user
assert_not_equal session_id, request.session["session_id"]
end
end
-class AuthenticationWithScopedViewsTest < ActionDispatch::IntegrationTest
+class AuthenticationWithScopedViewsTest < Devise::IntegrationTest
test 'renders the scoped view if turned on and view is available' do
swap Devise, scoped_views: true do
assert_raise Webrat::NotFoundError do
sign_in_as_user
end
@@ -429,11 +429,11 @@
end
end
end
end
-class AuthenticationOthersTest < ActionDispatch::IntegrationTest
+class AuthenticationOthersTest < Devise::IntegrationTest
test 'handles unverified requests gets rid of caches' do
swap ApplicationController, allow_forgery_protection: true do
post exhibit_user_url(1)
assert_not warden.authenticated?(:user)
@@ -470,11 +470,11 @@
end
end
test 'sign in with script name' do
assert_nothing_raised do
- get new_user_session_path, {}, "SCRIPT_NAME" => "/omg"
+ get new_user_session_path, headers: { "SCRIPT_NAME" => "/omg" }
fill_in "email", with: "user@test.com"
end
end
test 'sign in stub in xml format' do
@@ -507,27 +507,27 @@
assert_not warden.authenticated?(:admin)
end
test 'sign in with xml format returns xml response' do
create_user
- post user_session_path(format: 'xml'), user: {email: "user@test.com", password: '12345678'}
+ post user_session_path(format: 'xml'), params: { user: {email: "user@test.com", password: '12345678'} }
assert_response :success
assert response.body.include? %(<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<user>)
end
test 'sign in with xml format is idempotent' do
get new_user_session_path(format: 'xml')
assert_response :success
create_user
- post user_session_path(format: 'xml'), user: {email: "user@test.com", password: '12345678'}
+ post user_session_path(format: 'xml'), params: { user: {email: "user@test.com", password: '12345678'} }
assert_response :success
get new_user_session_path(format: 'xml')
assert_response :success
- post user_session_path(format: 'xml'), user: {email: "user@test.com", password: '12345678'}
+ post user_session_path(format: 'xml'), params: { user: {email: "user@test.com", password: '12345678'} }
assert_response :success
assert response.body.include? %(<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<user>)
end
test 'sign out with html redirects' do
@@ -557,28 +557,28 @@
end
test 'sign out with non-navigational format via XHR does not redirect' do
swap Devise, navigational_formats: ['*/*', :html] do
sign_in_as_user
- xml_http_request :get, destroy_user_session_path, {}, { "HTTP_ACCEPT" => "application/json,text/javascript,*/*" } # NOTE: Bug is triggered by combination of XHR and */*.
+ get destroy_user_session_path, xhr: true, headers: { "HTTP_ACCEPT" => "application/json,text/javascript,*/*" } # NOTE: Bug is triggered by combination of XHR and */*.
assert_response :no_content
assert_not warden.authenticated?(:user)
end
end
# Belt and braces ... Perhaps this test is not necessary?
test 'sign out with navigational format via XHR does redirect' do
swap Devise, navigational_formats: ['*/*', :html] do
sign_in_as_user
- xml_http_request :get, destroy_user_session_path, {}, { "HTTP_ACCEPT" => "text/html,*/*" }
+ get destroy_user_session_path, xhr: true, headers: { "HTTP_ACCEPT" => "text/html,*/*" }
assert_response :redirect
assert_not warden.authenticated?(:user)
end
end
end
-class AuthenticationKeysTest < ActionDispatch::IntegrationTest
+class AuthenticationKeysTest < Devise::IntegrationTest
test 'missing authentication keys cause authentication to abort' do
swap Devise, authentication_keys: [:subdomain] do
sign_in_as_user
assert_contain "Invalid subdomain or password."
assert_not warden.authenticated?(:user)
@@ -591,11 +591,11 @@
assert warden.authenticated?(:user)
end
end
end
-class AuthenticationRequestKeysTest < ActionDispatch::IntegrationTest
+class AuthenticationRequestKeysTest < Devise::IntegrationTest
test 'request keys are used on authentication' do
host! 'foo.bar.baz'
swap Devise, request_keys: [:subdomain] do
User.expects(:find_for_authentication).with(subdomain: 'foo', email: 'user@test.com').returns(create_user)
@@ -632,11 +632,11 @@
assert warden.authenticated?(:user)
end
end
end
-class AuthenticationSignOutViaTest < ActionDispatch::IntegrationTest
+class AuthenticationSignOutViaTest < Devise::IntegrationTest
def sign_in!(scope)
sign_in_as_admin(visit: send("new_#{scope}_session_path"))
assert warden.authenticated?(scope)
end
@@ -687,11 +687,11 @@
end
assert warden.authenticated?(:sign_out_via_delete_or_post)
end
end
-class DoubleAuthenticationRedirectTest < ActionDispatch::IntegrationTest
+class DoubleAuthenticationRedirectTest < Devise::IntegrationTest
test 'signed in as user redirects when visiting user sign in page' do
sign_in_as_user
get new_user_session_path(format: :html)
assert_redirected_to '/'
end
@@ -710,10 +710,10 @@
get new_admin_session_path(format: :html)
assert_redirected_to '/admin_area/home'
end
end
-class DoubleSignOutRedirectTest < ActionDispatch::IntegrationTest
+class DoubleSignOutRedirectTest < Devise::IntegrationTest
test 'sign out after already having signed out redirects to sign in' do
sign_in_as_user
post destroy_sign_out_via_delete_or_post_session_path