added test to confirm order in ALL is being adhered to when adding and including module in model

Signed-off-by: José Valim <jose.valim@gmail.com>
This commit is contained in:
Josh Kalderimis 2010-03-25 13:29:09 +01:00 committed by José Valim
parent c76df8239f
commit 4d3a3ceb43
1 changed files with 15 additions and 1 deletions

View File

@ -23,7 +23,21 @@ class ActiveRecordTest < ActiveSupport::TestCase
end
test 'add modules cherry pick' do
assert_include_modules Admin, :authenticatable, :registerable, :timeoutable, :recoverable
assert_include_modules Admin, :authenticatable, :registerable, :timeoutable
end
test 'order of module inclusion' do
correct_module_order = [:authenticatable, :registerable, :timeoutable]
incorrect_module_order = [:authenticatable, :timeoutable, :registerable]
assert_include_modules Admin, *incorrect_module_order
# get module constants from symbol list
module_constants = correct_module_order.collect { |mod| Devise::Models::const_get(mod.to_s.classify) }
# confirm that they adhere to the order in ALL
# get included modules, filter out the noise, and reverse the order
assert_equal module_constants, (Admin.included_modules & module_constants).reverse
end
test 'set a default value for stretches' do