Skip to content
Browse files

Add confirmable to admin.

  • Loading branch information...
1 parent df43ee6 commit 9a6ac7ab6922440a25016c3686c521d18a88b97d @josevalim josevalim committed Dec 11, 2011
View
4 test/integration/registerable_test.rb
@@ -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 @@ def teardown
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
1 test/mapping_test.rb
@@ -108,7 +108,6 @@ def fake_request(path, params={})
assert mapping.authenticatable?
assert mapping.recoverable?
assert mapping.lockable?
- assert_not mapping.confirmable?
assert_not mapping.omniauthable?
end
View
2 test/models/encryptable_test.rb
@@ -31,7 +31,7 @@ def swap_with_encryptor(klass, encryptor, options={})
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
8 test/models_test.rb
@@ -39,7 +39,7 @@ def assert_include_modules(klass, *modules)
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 @@ def assert_include_modules(klass, *modules)
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
6 test/rails_app/db/migrate/20100401102949_create_tables.rb
@@ -54,6 +54,12 @@ def self.up
## 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
4 test/rails_app/lib/shared_admin.rb
@@ -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
1 test/support/integration.rb
@@ -25,6 +25,7 @@ def create_admin(options={})
admin = Admin.create!(
:email => 'admin@test.com', :password => '123456', :password_confirmation => '123456'
)
+ admin.confirm! unless options[:confirm] == false
admin
end
end

0 comments on commit 9a6ac7a

Please sign in to comment.
Something went wrong with that request. Please try again.