Devise::Mapping#raw_path does not consider relative_url_root so that route helpers work (no more session_path(:user) => '/abc/abc/users/sign_in')

Devise::Mapping#parsed_path considers relative_url_root so that initial redirects still work with non empty relative_url_roots
This commit is contained in:
David Palm 2010-01-22 19:50:32 +08:00 committed by José Valim
parent e4e9e16623
commit bc05d28d3f
2 changed files with 14 additions and 14 deletions

View File

@ -94,7 +94,7 @@ module Devise
# Returns the raw path using the current relative_url_root, path_prefix and as.
def raw_path
ActionController::Base.relative_url_root.to_s + path_prefix + as.to_s
path_prefix + as.to_s
end
# Returns the parsed path. If you need meta information in your path_prefix,
@ -102,7 +102,7 @@ module Devise
# by default is I18n.locale.
#
def parsed_path
returning raw_path do |path|
returning (ActionController::Base.relative_url_root.to_s + raw_path) do |path|
self.class.default_url_options.each do |key, value|
path.gsub!(key.inspect, value.to_param)
end

View File

@ -97,18 +97,12 @@ class MappingTest < ActiveSupport::TestCase
assert_equal '/:locale/accounts', Devise.mappings[:manager].raw_path
end
test 'raw path adds in the relative_url_root' do
swap ActionController::Base, :relative_url_root => '/abc' do
assert_equal '/abc/users', Devise.mappings[:user].raw_path
end
end
test 'raw path deals with a nil relative_url_root' do
swap ActionController::Base, :relative_url_root => nil do
test 'raw path ignores the relative_url_root' do
swap ActionController::Base, :relative_url_root => "/abc" do
assert_equal '/users', Devise.mappings[:user].raw_path
end
end
test 'parsed path is returned' do
begin
Devise.default_url_options {{ :locale => I18n.locale }}
@ -119,12 +113,18 @@ class MappingTest < ActiveSupport::TestCase
end
end
test 'parsed path deals with non-standard relative_url_roots' do
swap ActionController::Base, :relative_url_root => "/abc" do
test 'parsed path adds in the relative_url_root' do
swap ActionController::Base, :relative_url_root => '/abc' do
assert_equal '/abc/users', Devise.mappings[:user].parsed_path
end
end
test 'parsed path deals with a nil relative_url_root' do
swap ActionController::Base, :relative_url_root => nil do
assert_equal '/users', Devise.mappings[:user].raw_path
end
end
test 'should have default route options' do
assert_equal({}, Devise.mappings[:user].route_options)
end