0
+ require 'action_controller'
0
+ if ENV['ACTIONCONTROLLER_PATH'].nil?
0
+Please set the ACTIONCONTROLLER_PATH environment variable to the directory
0
+containing the action_controller.rb file.
0
+ $LOAD_PATH.unshift << ENV['ACTIONCONTROLLER_PATH']
0
+ require 'action_controller'
0
+ abort "ActionController could not be found."
0
+require 'action_controller/test_process'
0
+require "#{File.dirname(__FILE__)}/../lib/ssl_requirement"
0
+ActionController::Base.logger = nil
0
+ActionController::Routing::Routes.reload rescue nil
0
+class SslRequirementController < ActionController::Base
0
+ include SslRequirement
0
+ render :nothing => true
0
+ render :nothing => true
0
+ render :nothing => true
0
+ render :nothing => true
0
+class SslRequirementTest < Test::Unit::TestCase
0
+ @controller = SslRequirementController.new
0
+ @request = ActionController::TestRequest.new
0
+ @response = ActionController::TestResponse.new
0
+ def test_redirect_to_https_preserves_flash
0
+ assert_response :redirect
0
+ assert_equal "bar", flash[:foo]
0
+ def test_not_redirecting_to_https_does_not_preserve_the_flash
0
+ assert_response :success
0
+ assert_nil flash[:foo]
0
+ def test_redirect_to_http_preserves_flash
0
+ @request.env['HTTPS'] = "on"
0
+ assert_response :redirect
0
+ assert_equal "bar", flash[:foo]
0
+ def test_not_redirecting_to_http_does_not_preserve_the_flash
0
+ @request.env['HTTPS'] = "on"
0
+ assert_response :success
0
+ assert_nil flash[:foo]
0
+ def test_required_without_ssl
0
+ assert_not_equal "on", @request.env["HTTPS"]
0
+ assert_response :redirect
0
+ assert_match %r{^https://}, @response.headers['Location']
0
+ assert_response :redirect
0
+ assert_match %r{^https://}, @response.headers['Location']
0
+ def test_required_with_ssl
0
+ @request.env['HTTPS'] = "on"
0
+ assert_response :success
0
+ assert_response :success
0
+ def test_disallowed_without_ssl
0
+ assert_not_equal "on", @request.env["HTTPS"]
0
+ assert_response :success
0
+ def test_disallowed_with_ssl
0
+ @request.env['HTTPS'] = "on"
0
+ assert_response :redirect
0
+ assert_match %r{^http://}, @response.headers['Location']
0
+ def test_allowed_without_ssl
0
+ assert_not_equal "on", @request.env["HTTPS"]
0
+ assert_response :success
0
+ def test_allowed_with_ssl
0
+ @request.env['HTTPS'] = "on"
0
+ assert_response :success
Comments
No one has commented yet.