mirror of
https://github.com/heartcombo/devise.git
synced 2026-01-23 05:38:04 -05:00
Use persisted? instead of new_record?
In order to be more ActiveModel compliant, lets use persisted? whereever we can. Particularly for datamapper, new_record? causes api warnings. Better to stick to the ActiveModel api I think.
This commit is contained in:
@@ -60,13 +60,13 @@ class ConfirmableTest < ActiveSupport::TestCase
|
||||
|
||||
test 'should return a new record with errors when a invalid token is given' do
|
||||
confirmed_user = User.confirm_by_token('invalid_confirmation_token')
|
||||
assert confirmed_user.new_record?
|
||||
assert_not confirmed_user.persisted?
|
||||
assert_equal "is invalid", confirmed_user.errors[:confirmation_token].join
|
||||
end
|
||||
|
||||
test 'should return a new record with errors when a blank token is given' do
|
||||
confirmed_user = User.confirm_by_token('')
|
||||
assert confirmed_user.new_record?
|
||||
assert_not confirmed_user.persisted?
|
||||
assert_equal "can't be blank", confirmed_user.errors[:confirmation_token].join
|
||||
end
|
||||
|
||||
@@ -119,7 +119,7 @@ class ConfirmableTest < ActiveSupport::TestCase
|
||||
|
||||
test 'should return a new user if no email was found' do
|
||||
confirmation_user = User.send_confirmation_instructions(:email => "invalid@email.com")
|
||||
assert confirmation_user.new_record?
|
||||
assert_not confirmation_user.persisted?
|
||||
end
|
||||
|
||||
test 'should add error to new user email if no email was found' do
|
||||
|
||||
@@ -156,13 +156,13 @@ class LockableTest < ActiveSupport::TestCase
|
||||
|
||||
test 'should return a new record with errors when a invalid token is given' do
|
||||
locked_user = User.unlock_access_by_token('invalid_token')
|
||||
assert locked_user.new_record?
|
||||
assert_not locked_user.persisted?
|
||||
assert_equal "is invalid", locked_user.errors[:unlock_token].join
|
||||
end
|
||||
|
||||
test 'should return a new record with errors when a blank token is given' do
|
||||
locked_user = User.unlock_access_by_token('')
|
||||
assert locked_user.new_record?
|
||||
assert_not locked_user.persisted?
|
||||
assert_equal "can't be blank", locked_user.errors[:unlock_token].join
|
||||
end
|
||||
|
||||
@@ -183,7 +183,7 @@ class LockableTest < ActiveSupport::TestCase
|
||||
|
||||
test 'should return a new user if no email was found' do
|
||||
unlock_user = User.send_unlock_instructions(:email => "invalid@email.com")
|
||||
assert unlock_user.new_record?
|
||||
assert_not unlock_user.persisted?
|
||||
end
|
||||
|
||||
test 'should add error to new user email if no email was found' do
|
||||
|
||||
@@ -82,7 +82,7 @@ class RecoverableTest < ActiveSupport::TestCase
|
||||
|
||||
test 'should return a new record with errors if user was not found by e-mail' do
|
||||
reset_password_user = User.send_reset_password_instructions(:email => "invalid@email.com")
|
||||
assert reset_password_user.new_record?
|
||||
assert_not reset_password_user.persisted?
|
||||
assert_equal "not found", reset_password_user.errors[:email].join
|
||||
end
|
||||
|
||||
@@ -110,13 +110,13 @@ class RecoverableTest < ActiveSupport::TestCase
|
||||
|
||||
test 'should a new record with errors if no reset_password_token is found' do
|
||||
reset_password_user = User.reset_password_by_token(:reset_password_token => 'invalid_token')
|
||||
assert reset_password_user.new_record?
|
||||
assert_not reset_password_user.persisted?
|
||||
assert_equal "is invalid", reset_password_user.errors[:reset_password_token].join
|
||||
end
|
||||
|
||||
test 'should a new record with errors if reset_password_token is blank' do
|
||||
reset_password_user = User.reset_password_by_token(:reset_password_token => '')
|
||||
assert reset_password_user.new_record?
|
||||
assert_not reset_password_user.persisted?
|
||||
assert_match "can't be blank", reset_password_user.errors[:reset_password_token].join
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user