Redirect to root after login if no path provided

If we do not do this, then people that login from /login will just be
redirected back to the login page. We'd rather have them see the root
path.
This commit is contained in:
Chris Hunt
2013-06-04 15:34:54 -07:00
parent 92a4828f72
commit 978785720a
2 changed files with 30 additions and 3 deletions

View File

@ -24,4 +24,26 @@ describe StaticController do
end
end
describe '#enter' do
context 'without a redirect path' do
it 'redirects to the root url' do
xhr :post, :enter
expect(response).to redirect_to root_path
end
end
context 'with a redirect path' do
it 'redirects to the redirect path' do
xhr :post, :enter, redirect: '/foo'
expect(response).to redirect_to '/foo'
end
end
context 'when the redirect path is the login page' do
it 'redirects to the root url' do
xhr :post, :enter, redirect: login_path
expect(response).to redirect_to root_path
end
end
end
end