Add confirmable to admin.

This commit is contained in:
José Valim 2011-12-11 19:53:07 +01:00
parent df43ee640d
commit 9a6ac7ab69
7 changed files with 16 additions and 10 deletions

View File

@ -13,7 +13,7 @@ class RegistrationTest < ActionController::IntegrationTest
fill_in 'password confirmation', :with => 'new_user123'
click_button 'Sign up'
assert_contain 'Welcome! You have signed up successfully.'
assert_contain 'You have signed up successfully'
assert warden.authenticated?(:admin)
assert_current_url "/admin_area/home"
@ -317,7 +317,7 @@ class ReconfirmableRegistrationTest < ActionController::IntegrationTest
assert_equal "user.new@example.com", User.first.unconfirmed_email
end
test 'A signed in user should not see a reconfirmation message if they did not change their password' do
test 'a signed in user should not see a reconfirmation message if they did not change their password' do
sign_in_as_user
get edit_user_registration_path

View File

@ -108,7 +108,6 @@ class MappingTest < ActiveSupport::TestCase
assert mapping.authenticatable?
assert mapping.recoverable?
assert mapping.lockable?
assert_not mapping.confirmable?
assert_not mapping.omniauthable?
end

View File

@ -31,7 +31,7 @@ class EncryptableTest < ActiveSupport::TestCase
test 'should generate a base64 hash using SecureRandom for password salt' do
swap_with_encryptor Admin, :sha1 do
SecureRandom.expects(:base64).with(15).returns('01lI')
SecureRandom.expects(:base64).with(15).returns('01lI').twice
salt = create_admin.password_salt
assert_not_equal '01lI', salt
assert_equal 4, salt.size

View File

@ -39,7 +39,7 @@ class ActiveRecordTest < ActiveSupport::TestCase
end
test 'can cherry pick modules' do
assert_include_modules Admin, :database_authenticatable, :registerable, :timeoutable, :recoverable, :lockable, :encryptable
assert_include_modules Admin, :database_authenticatable, :registerable, :timeoutable, :recoverable, :lockable, :encryptable, :confirmable
end
test 'validations options are not applied too late' do
@ -55,12 +55,12 @@ class ActiveRecordTest < ActiveSupport::TestCase
end
test 'chosen modules are inheritable' do
assert_include_modules Inheritable, :database_authenticatable, :registerable, :timeoutable, :recoverable, :lockable, :encryptable
assert_include_modules Inheritable, :database_authenticatable, :registerable, :timeoutable, :recoverable, :lockable, :encryptable, :confirmable
end
test 'order of module inclusion' do
correct_module_order = [:database_authenticatable, :encryptable, :recoverable, :registerable, :lockable, :timeoutable]
incorrect_module_order = [:database_authenticatable, :timeoutable, :registerable, :recoverable, :lockable, :encryptable]
correct_module_order = [:database_authenticatable, :encryptable, :recoverable, :registerable, :confirmable, :lockable, :timeoutable]
incorrect_module_order = [:database_authenticatable, :timeoutable, :registerable, :recoverable, :lockable, :encryptable, :confirmable]
assert_include_modules Admin, *incorrect_module_order

View File

@ -54,6 +54,12 @@ class CreateTables < ActiveRecord::Migration
## Rememberable
t.datetime :remember_created_at
## Confirmable
t.string :confirmation_token
t.datetime :confirmed_at
t.datetime :confirmation_sent_at
t.string :unconfirmed_email # Only if using reconfirmable
## Encryptable
t.string :password_salt

View File

@ -3,8 +3,8 @@ module SharedAdmin
included do
devise :database_authenticatable, :encryptable, :registerable,
:timeoutable, :recoverable, :lockable,
:unlock_strategy => :time, :lock_strategy => :none
:timeoutable, :recoverable, :lockable, :confirmable,
:unlock_strategy => :time, :lock_strategy => :none, :confirm_within => 2.weeks
end
end

View File

@ -25,6 +25,7 @@ class ActionDispatch::IntegrationTest
admin = Admin.create!(
:email => 'admin@test.com', :password => '123456', :password_confirmation => '123456'
)
admin.confirm! unless options[:confirm] == false
admin
end
end