test/models/lockable_test.rb in devise-3.0.0.rc vs test/models/lockable_test.rb in devise-3.0.0
- old
+ new
@@ -183,22 +183,31 @@
assert_equal unlock_user, user
end
end
test 'should require all unlock_keys' do
- swap Devise, :unlock_keys => [:username, :email] do
- user = create_user
- unlock_user = User.send_unlock_instructions(:email => user.email)
- assert_not unlock_user.persisted?
- assert_equal "can't be blank", unlock_user.errors[:username].join
- end
+ swap Devise, :unlock_keys => [:username, :email] do
+ user = create_user
+ unlock_user = User.send_unlock_instructions(:email => user.email)
+ assert_not unlock_user.persisted?
+ assert_equal "can't be blank", unlock_user.errors[:username].join
+ end
end
test 'should not be able to send instructions if the user is not locked' do
user = create_user
assert_not user.resend_unlock_token
assert_not user.access_locked?
assert_equal 'was not locked', user.errors[:email].join
+ end
+
+ test 'should not be able to send instructions if the user if not locked and have username as unlock key' do
+ swap Devise, :unlock_keys => [:username] do
+ user = create_user
+ assert_not user.resend_unlock_token
+ assert_not user.access_locked?
+ assert_equal 'was not locked', user.errors[:username].join
+ end
end
test 'should unlock account if lock has expired and increase attempts on failure' do
swap Devise, :unlock_in => 1.minute do
user = create_user