Commit 80cbe729eec095784fe0711941b22d49714251f2

Authored by AntonioTerceiro
1 parent ad82a7f6

ActionItem691: do not point to ssl when it is disabled by the

environment

git-svn-id: https://svn.colivre.coop.br/svn/noosfero/branches/0.11.x@2519 3f533792-8f58-4932-b0fe-aaf55b0a4547
app/helpers/application_helper.rb
... ... @@ -710,7 +710,7 @@ module ApplicationHelper
710 710  
711 711 def login_url
712 712 options = { :controller => 'account', :action => 'login' }
713   - options.merge!(:protocol => 'https://', :host => request.host) unless ENV['RAILS_ENV'] == 'development'
  713 + options.merge!(:protocol => 'https://', :host => request.host) unless ENV['RAILS_ENV'] == 'development' || environment.disable_ssl
714 714 url_for(options)
715 715 end
716 716  
... ...
test/unit/application_helper_test.rb
... ... @@ -221,6 +221,16 @@ class ApplicationHelperTest < Test::Unit::TestCase
221 221 assert_same foo, template_stylesheet_tag
222 222 end
223 223  
  224 + should 'not force ssl when environment has ssl disabled' do
  225 + environment = mock
  226 + environment.expects(:disable_ssl).returns(true).at_least_once
  227 + stubs(:environment).returns(environment)
  228 +
  229 + expects(:url_for).with(has_entries(:protocol => 'https://')).never
  230 + expects(:url_for).with(has_key(:controller)).returns("LALALA")
  231 + assert_equal "LALALA", login_url
  232 + end
  233 +
224 234 protected
225 235  
226 236 def content_tag(tag, content, options = {})
... ...