Fix ActiveRecord check on Confirmable (#4752)

* Fix `ActiveRecord` check on `Confirmable`

As pointed out by @dark-panda in #4302, the condition for an
`ActiveRecord` model is wrong inside the `Confirmable` initialization
block.

https://github.com/plataformatec/devise/pull/4302#issuecomment-355103489

* Add specs
This commit is contained in:
Leonardo Tegon
2018-01-16 10:25:20 -02:00
committed by GitHub
parent 371d657e35
commit d1948b79d3
2 changed files with 12 additions and 1 deletions

View File

@@ -8,6 +8,17 @@ class ConfirmableTest < ActiveSupport::TestCase
setup_mailer
end
test 'should set callbacks to send the mail' do
if DEVISE_ORM == :active_record
defined_callbacks = User._commit_callbacks.map(&:filter)
assert_includes defined_callbacks, :send_on_create_confirmation_instructions
assert_includes defined_callbacks, :send_reconfirmation_instructions
elsif DEVISE_ORM == :mongoid
assert_includes User._create_callbacks.map(&:filter), :send_on_create_confirmation_instructions
assert_includes User._update_callbacks.map(&:filter), :send_reconfirmation_instructions
end
end
test 'should generate confirmation token after creating a record' do
assert_nil new_user.confirmation_token
assert_not_nil create_user.confirmation_token