Required fields on confirmable

This commit is contained in:
Rodrigo Flores 2012-02-17 15:14:20 -02:00
parent 1bbae013cc
commit 6489354b0e
2 changed files with 16 additions and 0 deletions

View File

@ -36,6 +36,14 @@ module Devise
after_update :send_confirmation_instructions, :if => :reconfirmation_required?
end
module ModuleMethods
extend self
def required_fields
[:confirmation_token, :confirmed_at, :confirmation_sent_at]
end
end
# Confirm a user by setting it's confirmed_at to actual time. If the user
# is already confirmed, add an error to email field. If the user is invalid
# add errors

View File

@ -328,4 +328,12 @@ class ReconfirmableTest < ActiveSupport::TestCase
admin = Admin.find_by_unconfirmed_email_with_errors(:email => "new_test@email.com")
assert admin.persisted?
end
test 'required_fields should contain the fields that Devise uses' do
assert_equal Devise::Models::Confirmable::ModuleMethods.required_fields.sort, [
:confirmation_sent_at,
:confirmation_token,
:confirmed_at
]
end
end