Commit 73caa08ad4d7b03ca74e1a5fcca6cbb6d548a33c

Authored by Rodrigo Souto
1 parent 97633c05

Port was being duplicated on links

  This was happening because default_hostname and top_url were both
  adding the port.

(ActionItem2016)
app/models/environment.rb
... ... @@ -523,9 +523,6 @@ class Environment < ActiveRecord::Base
523 523 domain = (self.domains.find_by_is_default(true) || self.domains.find(:first, :order => 'id')).name
524 524 domain = email_hostname ? domain : (force_www ? ('www.' + domain) : domain)
525 525 end
526   - if Noosfero.url_options.has_key?(:port)
527   - domain += ":#{Noosfero.url_options[:port]}"
528   - end
529 526 domain
530 527 end
531 528  
... ...
test/unit/environment_test.rb
... ... @@ -234,11 +234,9 @@ class EnvironmentTest < Test::Unit::TestCase
234 234  
235 235 should 'include port in default top URL for development environment' do
236 236 env = Environment.new
237   - env.expects(:default_hostname).returns('www.lalala.net')
238   -
239 237 Noosfero.expects(:url_options).returns({ :port => 9999 }).at_least_once
240 238  
241   - assert_equal 'http://www.lalala.net:9999', env.top_url
  239 + assert_equal 'http://localhost:9999', env.top_url
242 240 end
243 241  
244 242 should 'use https when asked for a ssl url' do
... ... @@ -1119,10 +1117,10 @@ class EnvironmentTest < Test::Unit::TestCase
1119 1117 assert_equal ["Meter", "Kilo", "Litre"], Environment.default.units.map(&:singular)
1120 1118 end
1121 1119  
1122   - should 'include port in default hostname for development environment' do
  1120 + should 'not include port in default hostname' do
1123 1121 env = Environment.new
1124   - Noosfero.expects(:url_options).returns({ :port => 9999 }).at_least_once
1125   - assert_equal 'localhost:9999', env.default_hostname
  1122 + Noosfero.stubs(:url_options).returns({ :port => 9999 })
  1123 + assert_no_match /9999/, env.default_hostname
1126 1124 end
1127 1125  
1128 1126 end
... ...