Skip to content

Commit

Permalink
Use persisted? in order to check if the record was destoryed or not
Browse files Browse the repository at this point in the history
  • Loading branch information
José Valim committed May 7, 2013
1 parent 70199ed commit e499fad
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions test/models/database_authenticatable_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -198,20 +198,20 @@ class DatabaseAuthenticatableTest < ActiveSupport::TestCase
test 'should destroy user if current password is valid' do
user = create_user
assert user.destroy_with_password('12345678')
assert_nil User.find_by_id(user.id)
assert !user.persisted?
end

test 'should not destroy user with invalid password' do
user = create_user
assert_not user.destroy_with_password('other')
assert User.find(user.id)
assert user.persisted?
assert_match "is invalid", user.errors[:current_password].join
end

test 'should not destroy user with blank password' do
user = create_user
assert_not user.destroy_with_password(nil)
assert User.find(user.id)
assert user.persisted?
assert_match "can't be blank", user.errors[:current_password].join
end

Expand Down

0 comments on commit e499fad

Please sign in to comment.