Sha256: 12169bd187a8c3b157c7230115f0c61534f658dd2975f9bb9c5f27573e258f35

Contents?: true

Size: 1.78 KB

Versions: 13

Compression:

Stored size: 1.78 KB

Contents

require 'test_helper'

class DatabaseAuthenticationTest < ActionController::IntegrationTest
  test 'sign in with email of different case should succeed when email is in the list of case insensitive keys' do
    create_user(:email => 'Foo@Bar.com')
    
    sign_in_as_user do
      fill_in 'email', :with => 'foo@bar.com'
    end
    
    assert warden.authenticated?(:user)
  end

  test 'sign in with email of different case should fail when email is NOT the list of case insensitive keys' do
    swap Devise, :case_insensitive_keys => [] do
      create_user(:email => 'Foo@Bar.com')
      
      sign_in_as_user do
        fill_in 'email', :with => 'foo@bar.com'
      end
      
      assert_not warden.authenticated?(:user)
    end
  end

  test 'sign in should not authenticate if not using proper authentication keys' do
    swap Devise, :authentication_keys => [:username] do
      sign_in_as_user
      assert_not warden.authenticated?(:user)
    end
  end

  test 'sign in with invalid email should return to sign in form with error message' do
    sign_in_as_admin do
      fill_in 'email', :with => 'wrongemail@test.com'
    end

    assert_contain 'Invalid email or password'
    assert_not warden.authenticated?(:admin)
  end

  test 'sign in with invalid pasword should return to sign in form with error message' do
    sign_in_as_admin do
      fill_in 'password', :with => 'abcdef'
    end

    assert_contain 'Invalid email or password'
    assert_not warden.authenticated?(:admin)
  end

  test 'error message is configurable by resource name' do
    store_translations :en, :devise => { :failure => { :admin => { :invalid => "Invalid credentials" } } } do
      sign_in_as_admin do
        fill_in 'password', :with => 'abcdef'
      end

      assert_contain 'Invalid credentials'
    end
  end
end

Version data entries

13 entries across 13 versions & 3 rubygems

Version Path
devise_sociable-0.1.0 vendor/bundle/gems/devise-1.2.1/test/integration/database_authenticatable_test.rb
devise-1.3.4 test/integration/database_authenticatable_test.rb
devise-1.3.3 test/integration/database_authenticatable_test.rb
devise-1.3.2 test/integration/database_authenticatable_test.rb
devise-1.3.1 test/integration/database_authenticatable_test.rb
devise-1.3.0 test/integration/database_authenticatable_test.rb
devise-1.2.1 test/integration/database_authenticatable_test.rb
devise-1.2.0 test/integration/database_authenticatable_test.rb
devise-jdguyot-1.2.rc3 test/integration/database_authenticatable_test.rb
devise-1.2.rc2 test/integration/database_authenticatable_test.rb
devise-jdguyot-1.2.rc2 test/integration/database_authenticatable_test.rb
devise-jdguyot-1.2.rc test/integration/database_authenticatable_test.rb
devise-1.2.rc test/integration/database_authenticatable_test.rb