mirror of
https://github.com/heartcombo/devise.git
synced 2026-01-10 23:38:10 -05:00
Adding hook to authenticate method for testing if a user is already confirmed.
This commit is contained in:
@@ -2,6 +2,10 @@ require 'test_helper'
|
||||
|
||||
class ConfirmableTest < ActiveSupport::TestCase
|
||||
|
||||
def setup
|
||||
User.send :include, ::Devise::Confirmable
|
||||
end
|
||||
|
||||
test 'should not have confirmation code accessible' do
|
||||
assert_not field_accessible?(:confirmation_token)
|
||||
end
|
||||
@@ -88,24 +92,24 @@ class ConfirmableTest < ActiveSupport::TestCase
|
||||
assert confirmed_user.errors[:email]
|
||||
end
|
||||
|
||||
# test 'should not authenticate a user not confirmed' do
|
||||
# user = create_user
|
||||
# authenticated_user = User.authenticate(user.email, user.password)
|
||||
# assert_nil authenticated_user
|
||||
# end
|
||||
|
||||
# test 'should authenticate a confirmed user' do
|
||||
# user = create_user
|
||||
# user.confirm!
|
||||
# authenticated_user = User.authenticate(user.email, user.password)
|
||||
# assert_not_nil authenticated_user
|
||||
# assert_equal authenticated_user, user
|
||||
# end
|
||||
|
||||
test 'should send confirmation instructions by email' do
|
||||
assert_difference 'ActionMailer::Base.deliveries.size' do
|
||||
create_user
|
||||
end
|
||||
test 'should not authenticate a user not confirmed' do
|
||||
user = create_user
|
||||
authenticated_user = User.authenticate(user.email, user.password)
|
||||
assert_nil authenticated_user
|
||||
end
|
||||
|
||||
test 'should authenticate a confirmed user' do
|
||||
user = create_user
|
||||
user.confirm!
|
||||
authenticated_user = User.authenticate(user.email, user.password)
|
||||
assert_not_nil authenticated_user
|
||||
assert_equal authenticated_user, user
|
||||
end
|
||||
|
||||
# test 'should send confirmation instructions by email' do
|
||||
# assert_difference 'ActionMailer::Base.deliveries.size' do
|
||||
# create_user
|
||||
# end
|
||||
# end
|
||||
end
|
||||
|
||||
|
||||
@@ -16,14 +16,13 @@ ActiveRecord::Schema.define(:version => 1) do
|
||||
t.string :email, :null => false
|
||||
t.string :encrypted_password, :null => false
|
||||
t.string :password_salt, :null => false
|
||||
t.string :confirmation_token, :null => false
|
||||
t.string :confirmation_token
|
||||
t.datetime :confirmed_at
|
||||
end
|
||||
end
|
||||
|
||||
class User < ::ActiveRecord::Base
|
||||
include ::Devise::Authenticable
|
||||
include ::Devise::Confirmable
|
||||
end
|
||||
|
||||
ActionMailer::Base.delivery_method = :test
|
||||
|
||||
Reference in New Issue
Block a user