mirror of
https://github.com/heartcombo/devise.git
synced 2022-11-09 12:18:31 -05:00
Return Symbol in find_scope! if String passed
This commit is contained in:
parent
df43642cd5
commit
7b5293906b
3 changed files with 8 additions and 1 deletions
|
@ -33,7 +33,7 @@ module Devise
|
|||
def self.find_scope!(obj)
|
||||
case obj
|
||||
when String, Symbol
|
||||
return obj
|
||||
return obj.to_sym
|
||||
when Class
|
||||
Devise.mappings.each_value { |m| return m.name if obj <= m.to }
|
||||
else
|
||||
|
|
|
@ -13,6 +13,12 @@ class RoutesTest < ActionController::TestCase
|
|||
assert_equal @controller.send(:"#{prepend_path}#{name}_url", :user),
|
||||
send(:"#{prepend_path}user_#{name}_url")
|
||||
|
||||
# With string
|
||||
assert_equal @controller.send(:"#{prepend_path}#{name}_path", "user"),
|
||||
send(:"#{prepend_path}user_#{name}_path")
|
||||
assert_equal @controller.send(:"#{prepend_path}#{name}_url", "user"),
|
||||
send(:"#{prepend_path}user_#{name}_url")
|
||||
|
||||
# Default url params
|
||||
assert_equal @controller.send(:"#{prepend_path}#{name}_path", :user, param: 123),
|
||||
send(:"#{prepend_path}user_#{name}_path", param: 123)
|
||||
|
|
|
@ -62,6 +62,7 @@ class MappingTest < ActiveSupport::TestCase
|
|||
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")
|
||||
assert_equal :user, Devise::Mapping.find_scope!(User.new)
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue