Sha256: a7bf1b8fd3826c70a347ca6adee61a31619d3b0e574a323a64e3326f5d61dde5

Contents?: true

Size: 1019 Bytes

Versions: 11

Compression:

Stored size: 1019 Bytes

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

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

    sign_in user
    get :index

    sign_out user
    get :index
    assert_redirected_to "/users/sign_in?unauthenticated=true"
  end

  def create_user
    User.create!(:email => "jose.valim@plataformatec.com", :password => "123456")
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
devise-0.7.1 test/test_helpers_test.rb
devise-0.7.0 test/test_helpers_test.rb
devise-0.6.3 test/test_helpers_test.rb
devise-0.6.2 test/test_helpers_test.rb
devise-0.6.1 test/test_helpers_test.rb
devise-0.6.0 test/test_helpers_test.rb
devise-0.5.6 test/test_helpers_test.rb
devise-0.5.5 test/test_helpers_test.rb
devise-0.5.4 test/test_helpers_test.rb
devise-0.5.3 test/test_helpers_test.rb
devise-0.5.2 test/test_helpers_test.rb