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

60 lines
1.8 KiB
Ruby
Raw Normal View History

require 'test_helper'
2009-10-12 08:37:42 -03:00
2010-06-13 12:11:15 +02:00
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
2010-02-06 01:33:32 +01:00
test 'sign in should not authenticate if not using proper authentication keys' do
2009-11-15 03:31:13 -02:00
swap Devise, :authentication_keys => [:username] do
sign_in_as_user
assert_not warden.authenticated?(:user)
end
end
2010-02-06 01:33:32 +01:00
test 'sign in with invalid email should return to sign in form with error message' do
2009-10-12 08:37:42 -03:00
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
2010-02-06 01:33:32 +01:00
test 'sign in with invalid pasword should return to sign in form with error message' do
2009-10-12 08:37:42 -03:00
sign_in_as_admin do
fill_in 'password', :with => 'abcdef'
end
assert_contain 'Invalid email or password'
assert_not warden.authenticated?(:admin)
end
2009-10-12 10:18:14 -03:00
test 'error message is configurable by resource name' do
store_translations :en, :devise => { :failure => { :admin => { :invalid => "Invalid credentials" } } } do
2009-10-12 10:18:14 -03:00
sign_in_as_admin do
fill_in 'password', :with => 'abcdef'
end
assert_contain 'Invalid credentials'
end
end
2010-06-13 12:11:15 +02:00
end