1
0
Fork 0
mirror of https://github.com/heartcombo/devise.git synced 2022-11-09 12:18:31 -05:00

Creating new integration test simulating sign in and sign out with user and admin at same time.

This commit is contained in:
Carlos A. da Silva 2009-10-11 11:21:49 -03:00
parent 1226c3d8de
commit f840129815
5 changed files with 54 additions and 14 deletions

View file

@ -1,6 +1,6 @@
class SessionsController < ApplicationController
before_filter :authenticate!, :only => :destroy
before_filter :require_no_authentication, :except => :destroy
#before_filter :require_no_authentication, :except => :destroy
# GET /session/new
#

View file

@ -32,7 +32,9 @@ module Devise
redirect_to new_session_path(scope) unless authenticated?(scope)
end
# Helper for use in before_filters where no authentication is required:
# Helper for use in before_filters where no authentication is required.
# Please note that all scopes will be tested within this filter, and if
# one of then is authenticated the filter will redirect.
# Example:
# before_filter :require_no_authentication, :only => :new
#

View file

@ -2,12 +2,6 @@ require 'test/test_helper'
class AdminsAuthenticationTest < ActionController::IntegrationTest
test 'home should be accessible without signed in admins' do
visit '/'
assert_response :success
assert_template 'home/index'
end
test 'not signed in as admin should not be able to access admins actions' do
get admins_path

View file

@ -0,0 +1,50 @@
require 'test/test_helper'
class AuthenticationTest < ActionController::IntegrationTest
test 'home should be accessible without signed in admins' do
visit '/'
assert_response :success
assert_template 'home/index'
end
test 'sign in as user should not authenticate admin scope' do
sign_in_as_user
assert warden.authenticated?(:user)
assert_not warden.authenticated?(:admin)
end
test 'sign in as admin should not authenticate user scope' do
sign_in_as_admin
assert warden.authenticated?(:admin)
assert_not warden.authenticated?(:user)
end
test 'sign in as both user and admin at same time' do
sign_in_as_user
sign_in_as_admin
assert warden.authenticated?(:user)
assert warden.authenticated?(:admin)
end
test 'sign out as user should not touch admin authentication' do
sign_in_as_user
sign_in_as_admin
delete user_session_path
assert_not warden.authenticated?(:user)
assert warden.authenticated?(:admin)
end
test 'sign out as admin should not touch user authentication' do
sign_in_as_user
sign_in_as_admin
delete admin_session_path
assert_not warden.authenticated?(:admin)
assert warden.authenticated?(:user)
end
end

View file

@ -2,12 +2,6 @@ require 'test/test_helper'
class UsersAuthenticationTest < ActionController::IntegrationTest
test 'home should be accessible without signed in users' do
visit '/'
assert_response :success
assert_template 'home/index'
end
test 'not signed in as user should not be able to access users actions' do
get users_path