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 | 51 | end |
52 | 52 | def redirect_to_ssl |
53 | 53 | if environment.enable_ssl |
54 | - redirect_to(params.merge(:protocol => 'https://')) | |
54 | + redirect_to(params.merge(:protocol => 'https://', :host => ssl_hostname)) | |
55 | 55 | true |
56 | 56 | else |
57 | 57 | false | ... | ... |
test/functional/account_controller_test.rb
... | ... | @@ -590,6 +590,7 @@ class AccountControllerTest < Test::Unit::TestCase |
590 | 590 | end |
591 | 591 | |
592 | 592 | should 'force ssl' do |
593 | + Environment.default.update_attribute(:enable_ssl, true) | |
593 | 594 | @request.expects(:ssl?).returns(false).at_least_once |
594 | 595 | get :index |
595 | 596 | assert_redirected_to :protocol => 'https://' |
... | ... | @@ -608,6 +609,7 @@ class AccountControllerTest < Test::Unit::TestCase |
608 | 609 | end |
609 | 610 | |
610 | 611 | should 'point to SSL URL in login popup' do |
612 | + Environment.default.update_attribute(:enable_ssl, true) | |
611 | 613 | get :login_popup |
612 | 614 | assert_tag :tag => 'form', :attributes => { :action => /^https:\/\// } |
613 | 615 | end | ... | ... |
test/functional/admin_controller_test.rb
test/functional/application_controller_test.rb
... | ... | @@ -337,9 +337,10 @@ class ApplicationControllerTest < Test::Unit::TestCase |
337 | 337 | should 'return true in redirect_to_ssl' do |
338 | 338 | env = mock |
339 | 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 | 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 | 344 | assert_equal true, @controller.redirect_to_ssl |
344 | 345 | end |
345 | 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 | 672 | end |
673 | 673 | |
674 | 674 | should 'require ssl in general' do |
675 | + Environment.default.update_attribute(:enable_ssl, true) | |
675 | 676 | @request.expects(:ssl?).returns(false).at_least_once |
676 | 677 | get :index, :profile => 'testinguser' |
677 | 678 | assert_redirected_to :protocol => 'https://' |
... | ... | @@ -684,12 +685,14 @@ class CmsControllerTest < Test::Unit::TestCase |
684 | 685 | end |
685 | 686 | |
686 | 687 | should 'not loose type argument in new action when redirecting to ssl' do |
688 | + Environment.default.update_attribute(:enable_ssl, true) | |
687 | 689 | @request.expects(:ssl?).returns(false).at_least_once |
688 | 690 | get :new, :profile => 'testinguser', :type => 'Folder' |
689 | 691 | assert_redirected_to :protocol => 'https://', :action => 'new', :type => 'Folder' |
690 | 692 | end |
691 | 693 | |
692 | 694 | should 'not accept non-ajax connections to new action without ssl' do |
695 | + Environment.default.update_attribute(:enable_ssl, true) | |
693 | 696 | @request.expects(:ssl?).returns(false).at_least_once |
694 | 697 | get :new, :profile => 'testinguser' |
695 | 698 | assert_redirected_to :protocol => 'https://' | ... | ... |
test/functional/content_viewer_controller_test.rb
... | ... | @@ -543,6 +543,7 @@ class ContentViewerControllerTest < Test::Unit::TestCase |
543 | 543 | end |
544 | 544 | |
545 | 545 | should 'require SSL for viewing non-public articles' do |
546 | + Environment.default.update_attribute(:enable_ssl, true) | |
546 | 547 | page = profile.articles.create!(:name => 'myarticle', :body => 'top secret', :public_article => false) |
547 | 548 | get :view_page, :profile => 'testinguser', :page => [ 'myarticle' ] |
548 | 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 | 51 | end |
52 | 52 | |
53 | 53 | should 'require ssl' do |
54 | + Environment.default.update_attribute(:enable_ssl, true) | |
54 | 55 | @controller = OnlyForPersonTestController.new |
55 | 56 | org = Organization.create!(:identifier => 'hacking_institute', :name => 'Hacking Institute') |
56 | 57 | ... | ... |