From f32d1d5bd51f60a1c791520a6cadeb69fdcd84d2 Mon Sep 17 00:00:00 2001 From: Antonio Terceiro Date: Sat, 1 Aug 2009 14:44:48 -0300 Subject: [PATCH] ActionItem1165: fixing some tests --- app/controllers/application.rb | 2 +- test/functional/account_controller_test.rb | 2 ++ test/functional/admin_controller_test.rb | 1 + test/functional/application_controller_test.rb | 5 +++-- test/functional/cms_controller_test.rb | 3 +++ test/functional/content_viewer_controller_test.rb | 1 + test/functional/my_profile_controller_test.rb | 1 + 7 files changed, 12 insertions(+), 3 deletions(-) diff --git a/app/controllers/application.rb b/app/controllers/application.rb index cc3b22d..ed84847 100644 --- a/app/controllers/application.rb +++ b/app/controllers/application.rb @@ -51,7 +51,7 @@ class ApplicationController < ActionController::Base end def redirect_to_ssl if environment.enable_ssl - redirect_to(params.merge(:protocol => 'https://')) + redirect_to(params.merge(:protocol => 'https://', :host => ssl_hostname)) true else false diff --git a/test/functional/account_controller_test.rb b/test/functional/account_controller_test.rb index 94795a1..31af9f9 100644 --- a/test/functional/account_controller_test.rb +++ b/test/functional/account_controller_test.rb @@ -590,6 +590,7 @@ class AccountControllerTest < Test::Unit::TestCase end should 'force ssl' do + Environment.default.update_attribute(:enable_ssl, true) @request.expects(:ssl?).returns(false).at_least_once get :index assert_redirected_to :protocol => 'https://' @@ -608,6 +609,7 @@ class AccountControllerTest < Test::Unit::TestCase end should 'point to SSL URL in login popup' do + Environment.default.update_attribute(:enable_ssl, true) get :login_popup assert_tag :tag => 'form', :attributes => { :action => /^https:\/\// } end diff --git a/test/functional/admin_controller_test.rb b/test/functional/admin_controller_test.rb index b559c16..0b9c562 100644 --- a/test/functional/admin_controller_test.rb +++ b/test/functional/admin_controller_test.rb @@ -19,6 +19,7 @@ class AdminControllerTest < Test::Unit::TestCase end should 'require ssl' do + Environment.default.update_attribute(:enable_ssl, true) get :index assert_redirected_to :protocol => 'https://' end diff --git a/test/functional/application_controller_test.rb b/test/functional/application_controller_test.rb index c8d976d..cd9a11d 100644 --- a/test/functional/application_controller_test.rb +++ b/test/functional/application_controller_test.rb @@ -337,9 +337,10 @@ class ApplicationControllerTest < Test::Unit::TestCase should 'return true in redirect_to_ssl' do env = mock env.expects(:enable_ssl).returns(true) - @controller.expects(:environment).returns(env) + env.stubs(:default_hostname).returns('test.mydomain.net') + @controller.stubs(:environment).returns(env) @controller.expects(:params).returns({}) - @controller.expects(:redirect_to).with({:protocol => 'https://'}) + @controller.expects(:redirect_to).with({:protocol => 'https://', :host => 'test.mydomain.net'}) assert_equal true, @controller.redirect_to_ssl end should 'return false in redirect_to_ssl when ssl is disabled' do diff --git a/test/functional/cms_controller_test.rb b/test/functional/cms_controller_test.rb index d50a5ea..62f10e7 100644 --- a/test/functional/cms_controller_test.rb +++ b/test/functional/cms_controller_test.rb @@ -672,6 +672,7 @@ class CmsControllerTest < Test::Unit::TestCase end should 'require ssl in general' do + Environment.default.update_attribute(:enable_ssl, true) @request.expects(:ssl?).returns(false).at_least_once get :index, :profile => 'testinguser' assert_redirected_to :protocol => 'https://' @@ -684,12 +685,14 @@ class CmsControllerTest < Test::Unit::TestCase end should 'not loose type argument in new action when redirecting to ssl' do + Environment.default.update_attribute(:enable_ssl, true) @request.expects(:ssl?).returns(false).at_least_once get :new, :profile => 'testinguser', :type => 'Folder' assert_redirected_to :protocol => 'https://', :action => 'new', :type => 'Folder' end should 'not accept non-ajax connections to new action without ssl' do + Environment.default.update_attribute(:enable_ssl, true) @request.expects(:ssl?).returns(false).at_least_once get :new, :profile => 'testinguser' assert_redirected_to :protocol => 'https://' diff --git a/test/functional/content_viewer_controller_test.rb b/test/functional/content_viewer_controller_test.rb index 4a7d3bd..7125a64 100644 --- a/test/functional/content_viewer_controller_test.rb +++ b/test/functional/content_viewer_controller_test.rb @@ -543,6 +543,7 @@ class ContentViewerControllerTest < Test::Unit::TestCase end should 'require SSL for viewing non-public articles' do + Environment.default.update_attribute(:enable_ssl, true) page = profile.articles.create!(:name => 'myarticle', :body => 'top secret', :public_article => false) get :view_page, :profile => 'testinguser', :page => [ 'myarticle' ] assert_redirected_to :protocol => 'https://', :profile => 'testinguser', :page => [ 'myarticle' ] diff --git a/test/functional/my_profile_controller_test.rb b/test/functional/my_profile_controller_test.rb index 45ef1c2..eb4da9e 100644 --- a/test/functional/my_profile_controller_test.rb +++ b/test/functional/my_profile_controller_test.rb @@ -51,6 +51,7 @@ class MyProfileControllerTest < Test::Unit::TestCase end should 'require ssl' do + Environment.default.update_attribute(:enable_ssl, true) @controller = OnlyForPersonTestController.new org = Organization.create!(:identifier => 'hacking_institute', :name => 'Hacking Institute') -- libgit2 0.21.2