diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 6874deb..bfcccc2 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -721,7 +721,11 @@ module ApplicationHelper end def login_url - url_for(Noosfero.url_options.merge({ :controller => 'account', :action => 'login', :host => request.host })) + options = Noosfero.url_options.merge({ :controller => 'account', :action => 'login' }) + if !environment.disable_ssl && (ENV['RAILS_ENV'] != 'development') + options.merge!(:protocol => 'https://', :host => request.host) + end + url_for(options) end def base_url diff --git a/test/unit/application_helper_test.rb b/test/unit/application_helper_test.rb index 9c093b3..aa2677d 100644 --- a/test/unit/application_helper_test.rb +++ b/test/unit/application_helper_test.rb @@ -198,7 +198,18 @@ class ApplicationHelperTest < Test::Unit::TestCase assert_same foo, template_stylesheet_tag end - should 'not force ssl when environment has ssl disabled' do + should 'use https:// for login_url' do + environment = mock + environment.expects(:disable_ssl).returns(false) + stubs(:environment).returns(environment) + request = mock + request.stubs(:host).returns('myhost.net') + stubs(:request).returns(request) + stubs(:url_for).with(has_entries(:protocol => 'https://', :host => 'myhost.net')).returns('LALALA') + assert_equal 'LALALA', login_url + end + + should 'not force ssl in login_url when environment has ssl disabled' do environment = mock environment.expects(:disable_ssl).returns(true).at_least_once stubs(:environment).returns(environment) diff --git a/test/unit/blog_archives_block_test.rb b/test/unit/blog_archives_block_test.rb index 217294e..b4441ed 100644 --- a/test/unit/blog_archives_block_test.rb +++ b/test/unit/blog_archives_block_test.rb @@ -38,7 +38,7 @@ class BlogArchivesBlockTest < ActiveSupport::TestCase end block = BlogArchivesBlock.new block.stubs(:owner).returns(profile) - assert_tag_in_string block.content, :tag => 'a', :content => 'January (10)', :attributes => {:href => 'http://colivre.net/flatline/blog?month=01&year=2008' } + assert_tag_in_string block.content, :tag => 'a', :content => 'January (10)', :attributes => {:href => /^http:\/\/.*\/flatline\/blog\?month=01&year=2008$/ } end should 'order list of amount posts' do diff --git a/test/unit/profile_test.rb b/test/unit/profile_test.rb index a1d56bc..ad34754 100644 --- a/test/unit/profile_test.rb +++ b/test/unit/profile_test.rb @@ -261,7 +261,7 @@ class ProfileTest < Test::Unit::TestCase should 'provide URL to admin area' do profile = Profile.create!(:name => "Test Profile", :identifier => 'testprofile', :environment_id => create_environment('mycolivre.net').id) - assert_equal({ :host => 'mycolivre.net', :profile => 'testprofile', :controller => 'profile_editor', :action => 'index'}, profile.admin_url) + assert_equal({ :profile => 'testprofile', :controller => 'profile_editor', :action => 'index'}, profile.admin_url) end should 'provide URL to public profile' do -- libgit2 0.21.2