Devise::Mapping#raw_path considers the relative_url_root to fix issue with Passenger and RailsBaseURI directives

Signed-off-by: José Valim <jose.valim@gmail.com>
This commit is contained in:
David Palm 2010-01-12 16:54:58 +01:00 committed by José Valim
parent c4764c931a
commit 5ca178aa7e
3 changed files with 24 additions and 4 deletions

View File

@ -1,3 +1,5 @@
== 0.8.1
* enhancements
* Move salt to encryptors

View File

@ -92,9 +92,9 @@ module Devise
self.path_prefix.count("/")
end
# Returns the raw path using path_prefix and as.
# Returns the raw path using the current relative_url_root, path_prefix and as.
def raw_path
path_prefix + as.to_s
ActionController::Base.relative_url_root.to_s + path_prefix + as.to_s
end
# Returns the parsed path. If you need meta information in your path_prefix,

View File

@ -86,7 +86,7 @@ class MappingTest < ActiveSupport::TestCase
mapping = Devise.mappings[:manager]
assert_equal '/:locale/', mapping.path_prefix
end
test 'retrieve as from the proper position' do
assert_equal 1, Devise.mappings[:user].as_position
assert_equal 2, Devise.mappings[:manager].as_position
@ -96,6 +96,18 @@ class MappingTest < ActiveSupport::TestCase
assert_equal '/users', Devise.mappings[:user].raw_path
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
assert_equal '/users', Devise.mappings[:user].raw_path
end
end
test 'parsed path is returned' do
begin
@ -106,7 +118,13 @@ class MappingTest < ActiveSupport::TestCase
Devise.default_url_options {{ }}
end
end
test 'parsed path deals with non-standard relative_url_roots' do
swap ActionController::Base, :relative_url_root => "/abc" do
assert_equal '/abc/users', Devise.mappings[:user].parsed_path
end
end
test 'should have default route options' do
assert_equal({}, Devise.mappings[:user].route_options)
end