Documentation about confirm_in and remember_for configurations and some tests.

This commit is contained in:
Carlos A. da Silva 2009-10-22 09:49:19 -02:00
parent 18d87d5c58
commit 548b7a9b4d
4 changed files with 45 additions and 5 deletions

View File

@ -17,8 +17,18 @@ module Devise
#
# devise :all, :stretches => 20
#
# You can refer to Authenticable for more information about writing your own
# method to setup pepper and stretches.
# * confirm_in: the time you want your user to confirm it's account. During
# this time he will be able to access your application without confirming.
#
# devise :all, :confirm_in => 7.days
#
# * remember_for: the time the user will be remembered without asking for
# credentials again.
#
# devise :all, :remember_for => 2.weeks
#
# You can refer to Authenticable, Confirmable and Rememberable for more
# information about writing your own method to setup each model apart.
#
# Examples:
#

View File

@ -9,6 +9,16 @@ module Devise
# Whenever the user update it's email, his account is automatically unconfirmed,
# it means it won't be able to sign in again without confirming the account
# again through the email that was sent.
#
# Configuration:
#
# confirm_in: the time you want the user will have to confirm it's account
# without blocking his access. When confirm_in is zero, the
# user won't be able to sign in without confirming. You can
# use this to let your user access some features of your
# application without confirming the account, but blocking it
# after a certain period (ie 7 days).
#
# Examples:
#
# User.find(1).confirm! # returns true unless it's already confirmed

View File

@ -11,6 +11,15 @@ module Devise
# to lookup the record based on the saved information.
# You probably wouldn't use rememberable methods directly, they are used
# mostly internally for handling the remember token.
#
# Configuration:
#
# remember_for: the time you want the user will be remembered without
# asking for credentials. After this time the user will be
# blocked and will have to enter his credentials again.
# This configuration is also used to calculate the expires
# time for the cookie created to remember the user.
#
# Examples:
#
# User.find(1).remember_me! # regenerating the token

View File

@ -29,7 +29,10 @@ class Exceptable < User
end
class Configurable < User
devise :all, :stretches => 15, :pepper => 'abcdef'
devise :all, :stretches => 15,
:pepper => 'abcdef',
:confirm_in => 5.days,
:remember_for => 7.days
end
class ActiveRecordTest < ActiveSupport::TestCase
@ -87,11 +90,19 @@ class ActiveRecordTest < ActiveSupport::TestCase
end
test 'set a default value for stretches' do
assert_equal 15, Configurable.new.send(:stretches)
assert_equal 15, Configurable.new.stretches
end
test 'set a default value for pepper' do
assert_equal 'abcdef', Configurable.new.send(:pepper)
assert_equal 'abcdef', Configurable.new.pepper
end
test 'set a default value for confirm_in' do
assert_equal 5.days, Configurable.new.confirm_in
end
test 'set a default value for remember_for' do
assert_equal 7.days, Configurable.new.remember_for
end
test 'set null fields on migrations' do