Sha256: 3ce81d58dd5c0892f69aaf78458066bf59dc9efd77f3ae94f25708c0d7224659

Contents?: true

Size: 1.25 KB

Versions: 36

Compression:

Stored size: 1.25 KB

Contents

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
    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
      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
    assert_response :success
  end

  test "redirects if valid user signed out" do
    user = create_user
    user.confirm!

    sign_in user
    get :show

    sign_out user
    get :show
    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
end

Version data entries

36 entries across 31 versions & 7 rubygems

Version Path
graffititracker_devise-1.0.11 test/test_helpers_test.rb
devise-1.0.11 test/test_helpers_test.rb
devise-1.0.10 test/test_helpers_test.rb
devise_ennder-1.4.1.0.9 test/rails_app/vendor/plugins/devise/test/test_helpers_test.rb
devise_ennder-1.4.1.0.9 test/test_helpers_test.rb
devise_ennder-1.3.1.0.9 test/rails_app/vendor/plugins/devise/test/test_helpers_test.rb
devise_ennder-1.3.1.0.9 test/test_helpers_test.rb
devise_ennder-1.2.1.0.9 test/test_helpers_test.rb
devise_ennder-1.2.1.0.9 test/rails_app/vendor/plugins/devise/test/test_helpers_test.rb
devise_ennder-1.1.1.0.9 test/test_helpers_test.rb
devise_ennder-1.1.1.0.9 test/rails_app/vendor/plugins/devise/test/test_helpers_test.rb
devise_ennder-1.0.1.0.9 test/test_helpers_test.rb
devise_ennder-1.0.1.0.9 test/rails_app/vendor/plugins/devise/test/test_helpers_test.rb
devise-1.0.9 test/test_helpers_test.rb
dcu-devise-1.0.7 test/test_helpers_test.rb
devise-1.0.8 test/test_helpers_test.rb
ivanvc-devise-1.0.7.1 test/test_helpers_test.rb
mongoid-devise-1.0.1 test/test_helpers_test.rb
devise-1.0.7 test/test_helpers_test.rb
devise-1.0.6 test/test_helpers_test.rb