Stores the requested page before signing in and redirect the user to the stored uri after.

This commit is contained in:
Carlos A. da Silva
2009-10-17 11:12:50 -03:00
parent abfb33a040
commit a5cb147eb2
8 changed files with 60 additions and 32 deletions

View File

@@ -155,8 +155,26 @@ class AuthenticationTest < ActionController::IntegrationTest
end
test 'render 404 on roles without permission' do
get "admin_area/password/new"
get 'admin_area/password/new'
assert_response :not_found
assert_not_contain 'Send me reset password instructions'
end
test 'return to default url if no one was requested' do
sign_in_as_user
assert_template 'home/index'
assert_nil session[:return_to]
end
test 'return to given url after sign in' do
get users_path
assert_redirected_to new_user_session_path(:unauthenticated => true)
assert_equal users_path, session[:"user.return_to"]
follow_redirect!
sign_in_as_user :visit => false
assert_template 'users/index'
assert_nil session[:"user.return_to"]
end
end

View File

@@ -1,6 +1,6 @@
require 'test/test_helper'
class UsersConfirmationTest < ActionController::IntegrationTest
class ConfirmationTest < ActionController::IntegrationTest
test 'user should be able to request a new confirmation' do
user = create_user(:confirm => false)

View File

@@ -1,6 +1,6 @@
require 'test/test_helper'
class UsersPasswordRecoveryTest < ActionController::IntegrationTest
class PasswordTest < ActionController::IntegrationTest
def visit_new_password_path
visit new_user_session_path

View File

@@ -25,7 +25,7 @@ class ActionController::IntegrationTest
def sign_in_as_user(options={}, &block)
create_user(options)
visit new_user_session_path
visit new_user_session_path unless options[:visit] == false
fill_in 'email', :with => 'user@test.com'
fill_in 'password', :with => '123456'
yield if block_given?
@@ -34,7 +34,7 @@ class ActionController::IntegrationTest
def sign_in_as_admin(options={}, &block)
create_admin(options)
visit new_admin_session_path
visit new_admin_session_path unless options[:visit] == false
fill_in 'email', :with => 'admin@test.com'
fill_in 'password', :with => '123456'
yield if block_given?