diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2005-01-09 16:43:21 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2005-01-09 16:43:21 +0000 |
commit | cbd367b7fa232be37781bba1063c38d5ac36e94b (patch) | |
tree | d1b776eca6c20348175f190dec2682054434e212 /actionpack/test | |
parent | 75fca04590a310bedc66a455d7508168ae932ba4 (diff) | |
download | rails-cbd367b7fa232be37781bba1063c38d5ac36e94b.tar.gz rails-cbd367b7fa232be37781bba1063c38d5ac36e94b.tar.bz2 rails-cbd367b7fa232be37781bba1063c38d5ac36e94b.zip |
Added :before option to authentication
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@352 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/test')
-rw-r--r-- | actionpack/test/controller/authentication_test.rb | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/actionpack/test/controller/authentication_test.rb b/actionpack/test/controller/authentication_test.rb index abf0409d08..098d0596ff 100644 --- a/actionpack/test/controller/authentication_test.rb +++ b/actionpack/test/controller/authentication_test.rb @@ -2,7 +2,7 @@ require File.dirname(__FILE__) + '/../abstract_unit' class AuthenticationTest < Test::Unit::TestCase class ApplicationController < ActionController::Base - authentication :by => '@session[:authenticated]', :failure => { :controller => "login" } + authentication :by => '@session[:authenticated]', :before => '@session[:return_to] = "/weblog/"', :failure => { :controller => "login" } end class WeblogController < ApplicationController @@ -10,7 +10,10 @@ class AuthenticationTest < Test::Unit::TestCase def index() render_text "I indexed something" end def edit() render_text "I edited something" end def update() render_text "I updated something" end - def login() @session[:authenticated] = true; render_nothing end + def login + @session[:authenticated] = true + @session[:return_to] ? redirect_to_path(@session[:return_to]) : render_nothing + end end class AuthenticatesWeblogController < WeblogController @@ -86,4 +89,14 @@ class AuthenticationTest < Test::Unit::TestCase get :edit assert_success end + + def test_before_condition + @controller = AuthenticatesWeblogController.new + + get :edit + assert_redirected_to :controller => "login" + + get :login + assert_redirect_url "http://test.host/weblog/" + end end
\ No newline at end of file |