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

58 lines
1.3 KiB
Ruby
Raw Normal View History

2009-11-16 11:58:14 -05:00
require 'test/test_helper'
class TestHelpersTest < ActionController::TestCase
tests UsersController
include Devise::TestHelpers
test "redirects if attempting to access a page unauthenticated" do
get :show
2009-11-16 11:58:14 -05:00
assert_redirected_to "/users/sign_in?unauthenticated=true"
end
test "redirects if attempting to access a page with a unconfirmed account" do
swap Devise, :confirm_within => 0 do
sign_in create_user
get :show
2009-11-16 11:58:14 -05:00
assert_redirected_to "/users/sign_in?unconfirmed=true"
end
end
test "does not redirect with valid user" do
user = create_user
user.confirm!
sign_in user
get :show
2009-11-16 11:58:14 -05:00
assert_response :success
end
test "redirects if valid user signed out" do
user = create_user
user.confirm!
sign_in user
get :show
2009-11-16 11:58:14 -05:00
sign_out user
get :show
2009-11-16 11:58:14 -05:00
assert_redirected_to "/users/sign_in?unauthenticated=true"
end
test "allows to sign in with different users" do
first_user = create_user
first_user.confirm!
sign_in first_user
get :show
assert_equal first_user.id.to_s, @response.body
sign_out first_user
second_user = create_user
second_user.confirm!
sign_in second_user
get :show
assert_equal second_user.id.to_s, @response.body
end
2009-11-16 11:58:14 -05:00
end