diff --git a/app/controllers/admin/environment_role_manager_controller.rb b/app/controllers/admin/environment_role_manager_controller.rb index c5cda6d..e79c09a 100644 --- a/app/controllers/admin/environment_role_manager_controller.rb +++ b/app/controllers/admin/environment_role_manager_controller.rb @@ -1,4 +1,4 @@ -class EnvironmentRoleManagerController < ApplicationController +class EnvironmentRoleManagerController < AdminController protect 'manage_environment_roles', :environment def index diff --git a/app/controllers/admin/region_validators_controller.rb b/app/controllers/admin/region_validators_controller.rb index f755c1f..4388a7f 100644 --- a/app/controllers/admin/region_validators_controller.rb +++ b/app/controllers/admin/region_validators_controller.rb @@ -1,4 +1,4 @@ -class RegionValidatorsController < ApplicationController +class RegionValidatorsController < AdminController before_filter :load_region_and_search, :except => 'index' diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index 69655f9..809c220 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -1,2 +1,3 @@ class AdminController < ApplicationController + require_ssl end diff --git a/test/functional/admin_controller_test.rb b/test/functional/admin_controller_test.rb index a3c4c73..8ed9953 100644 --- a/test/functional/admin_controller_test.rb +++ b/test/functional/admin_controller_test.rb @@ -5,15 +5,28 @@ require 'admin_controller' class AdminController; def rescue_action(e) raise e end; end class AdminControllerTest < Test::Unit::TestCase + + class AdminTestController < AdminController + def index + render :text => 'ok', :layout => false + end + end + def setup - @controller = AdminController.new + @controller = AdminTestController.new @request = ActionController::TestRequest.new @response = ActionController::TestResponse.new end - # Replace this with your real tests. - def test_truth - assert true + should 'require ssl' do + get :index + assert_redirected_to :protocol => 'https://' + end + + should 'detect ssl' do + @request.expects(:ssl?).returns(true).at_least_once + get :index + assert_response :success end end diff --git a/test/functional/admin_panel_controller_test.rb b/test/functional/admin_panel_controller_test.rb index fa76400..129abea 100644 --- a/test/functional/admin_panel_controller_test.rb +++ b/test/functional/admin_panel_controller_test.rb @@ -10,6 +10,7 @@ class AdminPanelControllerTest < Test::Unit::TestCase def setup @controller = AdminPanelController.new @request = ActionController::TestRequest.new + @request.stubs(:ssl?).returns(true) @response = ActionController::TestResponse.new login_as(create_admin_user(Environment.default)) end diff --git a/test/functional/categories_controller_test.rb b/test/functional/categories_controller_test.rb index d7fb47e..c165810 100644 --- a/test/functional/categories_controller_test.rb +++ b/test/functional/categories_controller_test.rb @@ -9,6 +9,7 @@ class CategoriesControllerTest < Test::Unit::TestCase def setup @controller = CategoriesController.new @request = ActionController::TestRequest.new + @request.stubs(:ssl?).returns(true) @response = ActionController::TestResponse.new @env = Environment.create!(:name => "My test environment") diff --git a/test/functional/features_controller_test.rb b/test/functional/features_controller_test.rb index b06b159..a0e682c 100644 --- a/test/functional/features_controller_test.rb +++ b/test/functional/features_controller_test.rb @@ -10,6 +10,7 @@ class FeaturesControllerTest < Test::Unit::TestCase def setup @controller = FeaturesController.new @request = ActionController::TestRequest.new + @request.stubs(:ssl?).returns(true) @response = ActionController::TestResponse.new login_as(create_admin_user(Environment.find(2))) end diff --git a/test/functional/region_validators_controller_test.rb b/test/functional/region_validators_controller_test.rb index 32c5ffc..004f2cf 100644 --- a/test/functional/region_validators_controller_test.rb +++ b/test/functional/region_validators_controller_test.rb @@ -9,6 +9,7 @@ class RegionValidatorsControllerTest < Test::Unit::TestCase def setup @controller = RegionValidatorsController.new @request = ActionController::TestRequest.new + @request.stubs(:ssl?).returns(true) @response = ActionController::TestResponse.new login_as('ze') end diff --git a/test/functional/role_controller_test.rb b/test/functional/role_controller_test.rb index 94109db..3c37e4a 100644 --- a/test/functional/role_controller_test.rb +++ b/test/functional/role_controller_test.rb @@ -10,6 +10,7 @@ class RoleControllerTest < Test::Unit::TestCase def setup @controller = RoleController.new @request = ActionController::TestRequest.new + @request.stubs(:ssl?).returns(true) @response = ActionController::TestResponse.new @role = Role.find(:first) login_as(:ze) -- libgit2 0.21.2