test/integration/lockable_test.rb in devise-1.0.5 vs test/integration/lockable_test.rb in devise-1.0.6
- old
+ new
@@ -34,10 +34,20 @@
assert_template 'unlocks/new'
assert_contain 'not locked'
assert_equal 0, ActionMailer::Base.deliveries.size
end
+ test 'unlocked pages should not be available if email strategy is disabled' do
+ visit new_user_unlock_path
+ assert_response :success
+
+ swap Devise, :unlock_strategy => :time do
+ visit new_user_unlock_path
+ assert_response :not_found
+ end
+ end
+
test 'user with invalid unlock token should not be able to unlock an account' do
visit_user_unlock_with_token('invalid_token')
assert_response :success
assert_template 'unlocks/new'
@@ -58,18 +68,27 @@
end
test "sign in user automatically after unlocking it's account" do
user = create_user(:locked => true)
visit_user_unlock_with_token(user.unlock_token)
-
assert warden.authenticated?(:user)
end
test "user should not be able to sign in when locked" do
user = sign_in_as_user(:locked => true)
assert_template 'sessions/new'
assert_contain 'Your account is locked.'
assert_not warden.authenticated?(:user)
+ end
+
+ test "user should not send a new e-mail if already locked" do
+ user = create_user(:locked => true)
+ user.update_attribute(:failed_attempts, User.maximum_attempts + 1)
+ ActionMailer::Base.deliveries.clear
+
+ sign_in_as_user(:password => "invalid")
+ assert_contain 'Invalid email or password.'
+ assert ActionMailer::Base.deliveries.empty?
end
test 'error message is configurable by resource name' do
store_translations :en, :devise => {
:sessions => { :admin => { :locked => "You are locked!" } }