1
0
Fork 0
mirror of https://github.com/heartcombo/devise.git synced 2022-11-09 12:18:31 -05:00

Add fragment support for store_location_for

This commit is contained in:
Jimmy Bourassa 2014-11-05 16:52:40 -05:00
parent d67388ad98
commit 5dedd8c4cf
2 changed files with 8 additions and 1 deletions

View file

@ -35,7 +35,9 @@ module Devise
session_key = stored_location_key_for(resource_or_scope)
uri = parse_uri(location)
if uri
session[session_key] = [uri.path.sub(/\A\/+/, '/'), uri.query].compact.join('?')
path = [uri.path.sub(/\A\/+/, '/'), uri.query].compact.join('?')
path = [path, uri.fragment].compact.join('#')
session[session_key] = path
end
end

View file

@ -245,6 +245,11 @@ class ControllerAuthenticatableTest < ActionController::TestCase
assert_equal "/foo?bar=baz", @controller.stored_location_for(:user)
end
test 'store location for stores fragments' do
@controller.store_location_for(:user, "/foo#bar")
assert_equal "/foo#bar", @controller.stored_location_for(:user)
end
test 'after sign in path defaults to root path if none by was specified for the given scope' do
assert_equal root_path, @controller.after_sign_in_path_for(:user)
end