mirror of
https://github.com/heartcombo/devise.git
synced 2022-11-09 12:18:31 -05:00
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:
parent
c4764c931a
commit
5ca178aa7e
3 changed files with 24 additions and 4 deletions
|
@ -1,3 +1,5 @@
|
||||||
|
== 0.8.1
|
||||||
|
|
||||||
* enhancements
|
* enhancements
|
||||||
* Move salt to encryptors
|
* Move salt to encryptors
|
||||||
|
|
||||||
|
|
|
@ -92,9 +92,9 @@ module Devise
|
||||||
self.path_prefix.count("/")
|
self.path_prefix.count("/")
|
||||||
end
|
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
|
def raw_path
|
||||||
path_prefix + as.to_s
|
ActionController::Base.relative_url_root.to_s + path_prefix + as.to_s
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns the parsed path. If you need meta information in your path_prefix,
|
# Returns the parsed path. If you need meta information in your path_prefix,
|
||||||
|
|
|
@ -97,6 +97,18 @@ class MappingTest < ActiveSupport::TestCase
|
||||||
assert_equal '/:locale/accounts', Devise.mappings[:manager].raw_path
|
assert_equal '/:locale/accounts', Devise.mappings[:manager].raw_path
|
||||||
end
|
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
|
test 'parsed path is returned' do
|
||||||
begin
|
begin
|
||||||
Devise.default_url_options {{ :locale => I18n.locale }}
|
Devise.default_url_options {{ :locale => I18n.locale }}
|
||||||
|
@ -107,6 +119,12 @@ class MappingTest < ActiveSupport::TestCase
|
||||||
end
|
end
|
||||||
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
|
test 'should have default route options' do
|
||||||
assert_equal({}, Devise.mappings[:user].route_options)
|
assert_equal({}, Devise.mappings[:user].route_options)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue