0
+require File.dirname(__FILE__) + '/../abstract_unit'
0
+class VerificationTest < Test::Unit::TestCase
0
+ class TestController < ActionController::Base
0
+ verify :only => :guarded_one, :params => "one",
0
+ :redirect_to => { :action => "unguarded" }
0
+ verify :only => :guarded_two, :params => %w( one two ),
0
+ :redirect_to => { :action => "unguarded" }
0
+ verify :only => :guarded_with_flash, :params => "one",
0
+ :add_flash => { "notice" => "prereqs failed" },
0
+ :redirect_to => { :action => "unguarded" }
0
+ verify :only => :guarded_in_session, :session => "one",
0
+ :redirect_to => { :action => "unguarded" }
0
+ verify :only => [:multi_one, :multi_two], :session => %w( one two ),
0
+ :redirect_to => { :action => "unguarded" }
0
+ render_text "#{@params["one"]}"
0
+ def guarded_with_flash
0
+ render_text "#{@params["one"]}"
0
+ render_text "#{@params["one"]}:#{@params["two"]}"
0
+ def guarded_in_session
0
+ render_text "#{@session["one"]}"
0
+ render_text "#{@session["one"]}:#{@session["two"]}"
0
+ render_text "#{@session["two"]}:#{@session["one"]}"
0
+ render_text "#{@params["one"]}"
0
+ @controller = TestController.new
0
+ @request = ActionController::TestRequest.new
0
+ @response = ActionController::TestResponse.new
0
+ def test_guarded_one_with_prereqs
0
+ process "guarded_one", "one" => "here"
0
+ assert_equal "here", @response.body
0
+ def test_guarded_one_without_prereqs
0
+ assert_redirected_to :action => "unguarded"
0
+ def test_guarded_with_flash_with_prereqs
0
+ process "guarded_with_flash", "one" => "here"
0
+ assert_equal "here", @response.body
0
+ def test_guarded_with_flash_without_prereqs
0
+ process "guarded_with_flash"
0
+ assert_redirected_to :action => "unguarded"
0
+ assert_flash_equal "prereqs failed", "notice"
0
+ def test_guarded_two_with_prereqs
0
+ process "guarded_two", "one" => "here", "two" => "there"
0
+ assert_equal "here:there", @response.body
0
+ def test_guarded_two_without_prereqs_one
0
+ process "guarded_two", "two" => "there"
0
+ assert_redirected_to :action => "unguarded"
0
+ def test_guarded_two_without_prereqs_two
0
+ process "guarded_two", "one" => "here"
0
+ assert_redirected_to :action => "unguarded"
0
+ def test_guarded_two_without_prereqs_both
0
+ assert_redirected_to :action => "unguarded"
0
+ def test_unguarded_with_params
0
+ process "unguarded", "one" => "here"
0
+ assert_equal "here", @response.body
0
+ def test_unguarded_without_params
0
+ assert_equal "", @response.body
0
+ def test_guarded_in_session_with_prereqs
0
+ process "guarded_in_session", {}, "one" => "here"
0
+ assert_equal "here", @response.body
0
+ def test_guarded_in_session_without_prereqs
0
+ process "guarded_in_session"
0
+ assert_redirected_to :action => "unguarded"
0
+ def test_multi_one_with_prereqs
0
+ process "multi_one", {}, "one" => "here", "two" => "there"
0
+ assert_equal "here:there", @response.body
0
+ def test_multi_one_without_prereqs
0
+ assert_redirected_to :action => "unguarded"
0
+ def test_multi_two_with_prereqs
0
+ process "multi_two", {}, "one" => "here", "two" => "there"
0
+ assert_equal "there:here", @response.body
0
+ def test_multi_two_without_prereqs
0
+ assert_redirected_to :action => "unguarded"
Comments
No one has commented yet.