Commit dc356d387f39b26cb8738db07af076f428cc2ae9
1 parent
d31f0c9f
Exists in
master
and in
22 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 | 256 | end |
257 | 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 | 262 | if Noosfero.url_options.has_key?(:port) |
262 | 263 | result << ':' << Noosfero.url_options[:port].to_s |
263 | 264 | end | ... | ... |
app/views/layouts/application.rhtml
test/unit/environment_test.rb
... | ... | @@ -187,6 +187,12 @@ class EnvironmentTest < Test::Unit::TestCase |
187 | 187 | assert_equal 'http://www.lalala.net:9999', env.top_url |
188 | 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 | 196 | should 'provide an approval_method setting' do |
191 | 197 | env = Environment.new |
192 | 198 | ... | ... |