Update bundler, Rails and improve tests for previous commit.

This commit is contained in:
José Valim
2010-07-02 08:12:00 +02:00
parent e9fbb3d7ef
commit 18cccae82f
7 changed files with 342 additions and 10 deletions

View File

@@ -39,7 +39,7 @@ module Devise
# Attempt to find the mapped route for devise based on request path
def devise_mapping
@devise_mapping ||= begin
mapping = Devise::Mapping.find_by_path(request.path_info)
mapping = Devise::Mapping.find_by_path(request)
mapping ||= Devise.mappings[Devise.default_scope] if Devise.use_default_scope
mapping
end

View File

@@ -27,11 +27,15 @@ module Devise
# Loop through all mappings looking for a map that matches with the requested
# path (ie /users/sign_in). If a path prefix is given, it's taken into account.
def self.find_by_path(path)
def self.find_by_path(request)
Devise.mappings.each_value do |mapping|
route = path.split("/")[mapping.segment_position]
route = route.sub(/\.\w+$/, '') unless route.nil?
return mapping if route && mapping.path == route.to_sym
route, extra = request.path_info.split("/")[mapping.segment_position, 2]
next unless route
if !extra && (format = request.params[:format])
route.sub!(/\.#{format}$/, '')
end
return mapping if mapping.path == route.to_sym
end
nil
end