Commit 1bea1b4f79a84d9f83e386af750aea096e85d526
1 parent
221acbe3
Exists in
master
and in
28 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,7 +721,11 @@ module ApplicationHelper | ||
721 | end | 721 | end |
722 | 722 | ||
723 | def login_url | 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 | end | 729 | end |
726 | 730 | ||
727 | def base_url | 731 | def base_url |
test/unit/application_helper_test.rb
@@ -198,7 +198,18 @@ class ApplicationHelperTest < Test::Unit::TestCase | @@ -198,7 +198,18 @@ class ApplicationHelperTest < Test::Unit::TestCase | ||
198 | assert_same foo, template_stylesheet_tag | 198 | assert_same foo, template_stylesheet_tag |
199 | end | 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 | environment = mock | 213 | environment = mock |
203 | environment.expects(:disable_ssl).returns(true).at_least_once | 214 | environment.expects(:disable_ssl).returns(true).at_least_once |
204 | stubs(:environment).returns(environment) | 215 | stubs(:environment).returns(environment) |
test/unit/blog_archives_block_test.rb
@@ -38,7 +38,7 @@ class BlogArchivesBlockTest < ActiveSupport::TestCase | @@ -38,7 +38,7 @@ class BlogArchivesBlockTest < ActiveSupport::TestCase | ||
38 | end | 38 | end |
39 | block = BlogArchivesBlock.new | 39 | block = BlogArchivesBlock.new |
40 | block.stubs(:owner).returns(profile) | 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 | end | 42 | end |
43 | 43 | ||
44 | should 'order list of amount posts' do | 44 | should 'order list of amount posts' do |
test/unit/profile_test.rb
@@ -261,7 +261,7 @@ class ProfileTest < Test::Unit::TestCase | @@ -261,7 +261,7 @@ class ProfileTest < Test::Unit::TestCase | ||
261 | 261 | ||
262 | should 'provide URL to admin area' do | 262 | should 'provide URL to admin area' do |
263 | profile = Profile.create!(:name => "Test Profile", :identifier => 'testprofile', :environment_id => create_environment('mycolivre.net').id) | 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 | end | 265 | end |
266 | 266 | ||
267 | should 'provide URL to public profile' do | 267 | should 'provide URL to public profile' do |