Extract common logic into the same method.

This commit is contained in:
José Valim
2009-11-16 15:07:01 -02:00
parent 97a7f0ed51
commit de40777334
4 changed files with 24 additions and 32 deletions

View File

@@ -49,9 +49,15 @@ class MappingTest < ActiveSupport::TestCase
assert_equal Devise.mappings[:user], Devise::Mapping.find_by_class(klass)
end
test 'find mapping raises an error for invalid class' do
test 'find scope for a given object' do
assert_equal :user, Devise::Mapping.find_scope!(User)
assert_equal :user, Devise::Mapping.find_scope!(:user)
assert_equal :user, Devise::Mapping.find_scope!(User.new)
end
test 'find scope raises an error if cannot be found' do
assert_raise RuntimeError do
Devise::Mapping.find_by_class!(String)
Devise::Mapping.find_scope!(String)
end
end