Commit f32d1d5bd51f60a1c791520a6cadeb69fdcd84d2
1 parent
cfac63da
Exists in
master
and in
29 other branches
ActionItem1165: fixing some tests
Showing
7 changed files
with
12 additions
and
3 deletions
Show diff stats
app/controllers/application.rb
@@ -51,7 +51,7 @@ class ApplicationController < ActionController::Base | @@ -51,7 +51,7 @@ class ApplicationController < ActionController::Base | ||
51 | end | 51 | end |
52 | def redirect_to_ssl | 52 | def redirect_to_ssl |
53 | if environment.enable_ssl | 53 | if environment.enable_ssl |
54 | - redirect_to(params.merge(:protocol => 'https://')) | 54 | + redirect_to(params.merge(:protocol => 'https://', :host => ssl_hostname)) |
55 | true | 55 | true |
56 | else | 56 | else |
57 | false | 57 | false |
test/functional/account_controller_test.rb
@@ -590,6 +590,7 @@ class AccountControllerTest < Test::Unit::TestCase | @@ -590,6 +590,7 @@ class AccountControllerTest < Test::Unit::TestCase | ||
590 | end | 590 | end |
591 | 591 | ||
592 | should 'force ssl' do | 592 | should 'force ssl' do |
593 | + Environment.default.update_attribute(:enable_ssl, true) | ||
593 | @request.expects(:ssl?).returns(false).at_least_once | 594 | @request.expects(:ssl?).returns(false).at_least_once |
594 | get :index | 595 | get :index |
595 | assert_redirected_to :protocol => 'https://' | 596 | assert_redirected_to :protocol => 'https://' |
@@ -608,6 +609,7 @@ class AccountControllerTest < Test::Unit::TestCase | @@ -608,6 +609,7 @@ class AccountControllerTest < Test::Unit::TestCase | ||
608 | end | 609 | end |
609 | 610 | ||
610 | should 'point to SSL URL in login popup' do | 611 | should 'point to SSL URL in login popup' do |
612 | + Environment.default.update_attribute(:enable_ssl, true) | ||
611 | get :login_popup | 613 | get :login_popup |
612 | assert_tag :tag => 'form', :attributes => { :action => /^https:\/\// } | 614 | assert_tag :tag => 'form', :attributes => { :action => /^https:\/\// } |
613 | end | 615 | end |
test/functional/admin_controller_test.rb
@@ -19,6 +19,7 @@ class AdminControllerTest < Test::Unit::TestCase | @@ -19,6 +19,7 @@ class AdminControllerTest < Test::Unit::TestCase | ||
19 | end | 19 | end |
20 | 20 | ||
21 | should 'require ssl' do | 21 | should 'require ssl' do |
22 | + Environment.default.update_attribute(:enable_ssl, true) | ||
22 | get :index | 23 | get :index |
23 | assert_redirected_to :protocol => 'https://' | 24 | assert_redirected_to :protocol => 'https://' |
24 | end | 25 | end |
test/functional/application_controller_test.rb
@@ -337,9 +337,10 @@ class ApplicationControllerTest < Test::Unit::TestCase | @@ -337,9 +337,10 @@ class ApplicationControllerTest < Test::Unit::TestCase | ||
337 | should 'return true in redirect_to_ssl' do | 337 | should 'return true in redirect_to_ssl' do |
338 | env = mock | 338 | env = mock |
339 | env.expects(:enable_ssl).returns(true) | 339 | env.expects(:enable_ssl).returns(true) |
340 | - @controller.expects(:environment).returns(env) | 340 | + env.stubs(:default_hostname).returns('test.mydomain.net') |
341 | + @controller.stubs(:environment).returns(env) | ||
341 | @controller.expects(:params).returns({}) | 342 | @controller.expects(:params).returns({}) |
342 | - @controller.expects(:redirect_to).with({:protocol => 'https://'}) | 343 | + @controller.expects(:redirect_to).with({:protocol => 'https://', :host => 'test.mydomain.net'}) |
343 | assert_equal true, @controller.redirect_to_ssl | 344 | assert_equal true, @controller.redirect_to_ssl |
344 | end | 345 | end |
345 | should 'return false in redirect_to_ssl when ssl is disabled' do | 346 | should 'return false in redirect_to_ssl when ssl is disabled' do |
test/functional/cms_controller_test.rb
@@ -672,6 +672,7 @@ class CmsControllerTest < Test::Unit::TestCase | @@ -672,6 +672,7 @@ class CmsControllerTest < Test::Unit::TestCase | ||
672 | end | 672 | end |
673 | 673 | ||
674 | should 'require ssl in general' do | 674 | should 'require ssl in general' do |
675 | + Environment.default.update_attribute(:enable_ssl, true) | ||
675 | @request.expects(:ssl?).returns(false).at_least_once | 676 | @request.expects(:ssl?).returns(false).at_least_once |
676 | get :index, :profile => 'testinguser' | 677 | get :index, :profile => 'testinguser' |
677 | assert_redirected_to :protocol => 'https://' | 678 | assert_redirected_to :protocol => 'https://' |
@@ -684,12 +685,14 @@ class CmsControllerTest < Test::Unit::TestCase | @@ -684,12 +685,14 @@ class CmsControllerTest < Test::Unit::TestCase | ||
684 | end | 685 | end |
685 | 686 | ||
686 | should 'not loose type argument in new action when redirecting to ssl' do | 687 | should 'not loose type argument in new action when redirecting to ssl' do |
688 | + Environment.default.update_attribute(:enable_ssl, true) | ||
687 | @request.expects(:ssl?).returns(false).at_least_once | 689 | @request.expects(:ssl?).returns(false).at_least_once |
688 | get :new, :profile => 'testinguser', :type => 'Folder' | 690 | get :new, :profile => 'testinguser', :type => 'Folder' |
689 | assert_redirected_to :protocol => 'https://', :action => 'new', :type => 'Folder' | 691 | assert_redirected_to :protocol => 'https://', :action => 'new', :type => 'Folder' |
690 | end | 692 | end |
691 | 693 | ||
692 | should 'not accept non-ajax connections to new action without ssl' do | 694 | should 'not accept non-ajax connections to new action without ssl' do |
695 | + Environment.default.update_attribute(:enable_ssl, true) | ||
693 | @request.expects(:ssl?).returns(false).at_least_once | 696 | @request.expects(:ssl?).returns(false).at_least_once |
694 | get :new, :profile => 'testinguser' | 697 | get :new, :profile => 'testinguser' |
695 | assert_redirected_to :protocol => 'https://' | 698 | assert_redirected_to :protocol => 'https://' |
test/functional/content_viewer_controller_test.rb
@@ -543,6 +543,7 @@ class ContentViewerControllerTest < Test::Unit::TestCase | @@ -543,6 +543,7 @@ class ContentViewerControllerTest < Test::Unit::TestCase | ||
543 | end | 543 | end |
544 | 544 | ||
545 | should 'require SSL for viewing non-public articles' do | 545 | should 'require SSL for viewing non-public articles' do |
546 | + Environment.default.update_attribute(:enable_ssl, true) | ||
546 | page = profile.articles.create!(:name => 'myarticle', :body => 'top secret', :public_article => false) | 547 | page = profile.articles.create!(:name => 'myarticle', :body => 'top secret', :public_article => false) |
547 | get :view_page, :profile => 'testinguser', :page => [ 'myarticle' ] | 548 | get :view_page, :profile => 'testinguser', :page => [ 'myarticle' ] |
548 | assert_redirected_to :protocol => 'https://', :profile => 'testinguser', :page => [ 'myarticle' ] | 549 | assert_redirected_to :protocol => 'https://', :profile => 'testinguser', :page => [ 'myarticle' ] |
test/functional/my_profile_controller_test.rb
@@ -51,6 +51,7 @@ class MyProfileControllerTest < Test::Unit::TestCase | @@ -51,6 +51,7 @@ class MyProfileControllerTest < Test::Unit::TestCase | ||
51 | end | 51 | end |
52 | 52 | ||
53 | should 'require ssl' do | 53 | should 'require ssl' do |
54 | + Environment.default.update_attribute(:enable_ssl, true) | ||
54 | @controller = OnlyForPersonTestController.new | 55 | @controller = OnlyForPersonTestController.new |
55 | org = Organization.create!(:identifier => 'hacking_institute', :name => 'Hacking Institute') | 56 | org = Organization.create!(:identifier => 'hacking_institute', :name => 'Hacking Institute') |
56 | 57 |