mirror of
https://github.com/heartcombo/devise.git
synced 2022-11-09 12:18:31 -05:00
Do not silently ignore invalid modules passed to devise method in model.
The & operator seemed to be only used to force sorting, but as a side effect we got suboptimal error handling.
This commit is contained in:
parent
692f7b27ff
commit
fa239b984a
2 changed files with 9 additions and 1 deletions
|
@ -47,7 +47,9 @@ module Devise
|
|||
def devise(*modules)
|
||||
include Devise::Models::Authenticatable
|
||||
options = modules.extract_options!
|
||||
self.devise_modules += Devise::ALL & modules.map(&:to_sym).uniq
|
||||
self.devise_modules += modules.map(&:to_sym).uniq.sort do |s1, s2|
|
||||
Devise::ALL.index(s1) <=> Devise::ALL.index(s2) # follow Devise::ALL order
|
||||
end
|
||||
|
||||
devise_modules_hook! do
|
||||
devise_modules.each { |m| include Devise::Models.const_get(m.to_s.classify) }
|
||||
|
|
|
@ -47,6 +47,12 @@ class ActiveRecordTest < ActiveSupport::TestCase
|
|||
assert_equal module_constants, (Admin.included_modules & module_constants).reverse
|
||||
end
|
||||
|
||||
test 'raise error on invalid module' do
|
||||
assert_raise NameError do
|
||||
Configurable.class_eval { devise :doesnotexist }
|
||||
end
|
||||
end
|
||||
|
||||
test 'set a default value for stretches' do
|
||||
assert_equal 15, Configurable.stretches
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue