Commit dc356d387f39b26cb8738db07af076f428cc2ae9
1 parent
d31f0c9f
Exists in
master
and in
28 other branches
ActionItem438: base URL must be SSL-aware
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@2470 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
4 changed files
with
14 additions
and
3 deletions
Show diff stats
app/helpers/application_helper.rb
app/models/environment.rb
| @@ -256,8 +256,9 @@ class Environment < ActiveRecord::Base | @@ -256,8 +256,9 @@ class Environment < ActiveRecord::Base | ||
| 256 | end | 256 | end |
| 257 | end | 257 | end |
| 258 | 258 | ||
| 259 | - def top_url | ||
| 260 | - result = "http://#{default_hostname}" | 259 | + def top_url(ssl = false) |
| 260 | + protocol = (ssl ? 'https' : 'http') | ||
| 261 | + result = "#{protocol}://#{default_hostname}" | ||
| 261 | if Noosfero.url_options.has_key?(:port) | 262 | if Noosfero.url_options.has_key?(:port) |
| 262 | result << ':' << Noosfero.url_options[:port].to_s | 263 | result << ':' << Noosfero.url_options[:port].to_s |
| 263 | end | 264 | end |
app/views/layouts/application.rhtml
| @@ -50,7 +50,7 @@ | @@ -50,7 +50,7 @@ | ||
| 50 | <%# FIXME %> | 50 | <%# FIXME %> |
| 51 | <%= stylesheet_link_tag '/designs/icons/default/style.css' %> | 51 | <%= stylesheet_link_tag '/designs/icons/default/style.css' %> |
| 52 | 52 | ||
| 53 | - <base href="<%= environment.top_url %>"/> | 53 | + <base href="<%= base_url %>"/> |
| 54 | </head> | 54 | </head> |
| 55 | 55 | ||
| 56 | <body class='noosfero category<%= category_color %><%= | 56 | <body class='noosfero category<%= category_color %><%= |
test/unit/environment_test.rb
| @@ -187,6 +187,12 @@ class EnvironmentTest < Test::Unit::TestCase | @@ -187,6 +187,12 @@ class EnvironmentTest < Test::Unit::TestCase | ||
| 187 | assert_equal 'http://www.lalala.net:9999', env.top_url | 187 | assert_equal 'http://www.lalala.net:9999', env.top_url |
| 188 | end | 188 | end |
| 189 | 189 | ||
| 190 | + should 'use https when asked for a ssl url' do | ||
| 191 | + env = Environment.new | ||
| 192 | + env.expects(:default_hostname).returns('www.lalala.net') | ||
| 193 | + assert_equal 'https://www.lalala.net', env.top_url(true) | ||
| 194 | + end | ||
| 195 | + | ||
| 190 | should 'provide an approval_method setting' do | 196 | should 'provide an approval_method setting' do |
| 191 | env = Environment.new | 197 | env = Environment.new |
| 192 | 198 |