Commit 1bea1b4f79a84d9f83e386af750aea096e85d526
1 parent
221acbe3
Exists in
master
and in
22 other branches
ActionItem1032: making some tests pass
Showing
4 changed files
with
19 additions
and
4 deletions
Show diff stats
app/helpers/application_helper.rb
| ... | ... | @@ -721,7 +721,11 @@ module ApplicationHelper |
| 721 | 721 | end |
| 722 | 722 | |
| 723 | 723 | def login_url |
| 724 | - url_for(Noosfero.url_options.merge({ :controller => 'account', :action => 'login', :host => request.host })) | |
| 724 | + options = Noosfero.url_options.merge({ :controller => 'account', :action => 'login' }) | |
| 725 | + if !environment.disable_ssl && (ENV['RAILS_ENV'] != 'development') | |
| 726 | + options.merge!(:protocol => 'https://', :host => request.host) | |
| 727 | + end | |
| 728 | + url_for(options) | |
| 725 | 729 | end |
| 726 | 730 | |
| 727 | 731 | def base_url | ... | ... |
test/unit/application_helper_test.rb
| ... | ... | @@ -198,7 +198,18 @@ class ApplicationHelperTest < Test::Unit::TestCase |
| 198 | 198 | assert_same foo, template_stylesheet_tag |
| 199 | 199 | end |
| 200 | 200 | |
| 201 | - should 'not force ssl when environment has ssl disabled' do | |
| 201 | + should 'use https:// for login_url' do | |
| 202 | + environment = mock | |
| 203 | + environment.expects(:disable_ssl).returns(false) | |
| 204 | + stubs(:environment).returns(environment) | |
| 205 | + request = mock | |
| 206 | + request.stubs(:host).returns('myhost.net') | |
| 207 | + stubs(:request).returns(request) | |
| 208 | + stubs(:url_for).with(has_entries(:protocol => 'https://', :host => 'myhost.net')).returns('LALALA') | |
| 209 | + assert_equal 'LALALA', login_url | |
| 210 | + end | |
| 211 | + | |
| 212 | + should 'not force ssl in login_url when environment has ssl disabled' do | |
| 202 | 213 | environment = mock |
| 203 | 214 | environment.expects(:disable_ssl).returns(true).at_least_once |
| 204 | 215 | stubs(:environment).returns(environment) | ... | ... |
test/unit/blog_archives_block_test.rb
| ... | ... | @@ -38,7 +38,7 @@ class BlogArchivesBlockTest < ActiveSupport::TestCase |
| 38 | 38 | end |
| 39 | 39 | block = BlogArchivesBlock.new |
| 40 | 40 | block.stubs(:owner).returns(profile) |
| 41 | - assert_tag_in_string block.content, :tag => 'a', :content => 'January (10)', :attributes => {:href => 'http://colivre.net/flatline/blog?month=01&year=2008' } | |
| 41 | + assert_tag_in_string block.content, :tag => 'a', :content => 'January (10)', :attributes => {:href => /^http:\/\/.*\/flatline\/blog\?month=01&year=2008$/ } | |
| 42 | 42 | end |
| 43 | 43 | |
| 44 | 44 | should 'order list of amount posts' do | ... | ... |
test/unit/profile_test.rb
| ... | ... | @@ -261,7 +261,7 @@ class ProfileTest < Test::Unit::TestCase |
| 261 | 261 | |
| 262 | 262 | should 'provide URL to admin area' do |
| 263 | 263 | profile = Profile.create!(:name => "Test Profile", :identifier => 'testprofile', :environment_id => create_environment('mycolivre.net').id) |
| 264 | - assert_equal({ :host => 'mycolivre.net', :profile => 'testprofile', :controller => 'profile_editor', :action => 'index'}, profile.admin_url) | |
| 264 | + assert_equal({ :profile => 'testprofile', :controller => 'profile_editor', :action => 'index'}, profile.admin_url) | |
| 265 | 265 | end |
| 266 | 266 | |
| 267 | 267 | should 'provide URL to public profile' do | ... | ... |