Commit 5a1392b5c7e16dbe29b10d5496f13747ed5cfa4a
1 parent
ec99374e
Exists in
master
and in
29 other branches
ActionItem1032: small fix in url generation scheme
Showing
2 changed files
with
9 additions
and
4 deletions
Show diff stats
app/models/profile.rb
... | ... | @@ -344,7 +344,7 @@ class Profile < ActiveRecord::Base |
344 | 344 | end |
345 | 345 | |
346 | 346 | def url_options |
347 | - options = { :host => default_hostname, :profile => (hostname ? nil : self.identifier) } | |
347 | + options = { :host => default_hostname, :profile => (own_hostname ? nil : self.identifier) } | |
348 | 348 | Noosfero.url_options.merge(options) |
349 | 349 | end |
350 | 350 | |
... | ... | @@ -356,11 +356,15 @@ class Profile < ActiveRecord::Base |
356 | 356 | if preferred_domain |
357 | 357 | return preferred_domain.name |
358 | 358 | else |
359 | - domain = self.domains.first | |
360 | - domain ? domain.name : nil | |
359 | + own_hostname | |
361 | 360 | end |
362 | 361 | end |
363 | 362 | |
363 | + def own_hostname | |
364 | + domain = self.domains.first | |
365 | + domain ? domain.name : nil | |
366 | + end | |
367 | + | |
364 | 368 | def possible_domains |
365 | 369 | environment.domains + domains |
366 | 370 | end | ... | ... |
test/unit/profile_test.rb
... | ... | @@ -1282,9 +1282,10 @@ class ProfileTest < Test::Unit::TestCase |
1282 | 1282 | end |
1283 | 1283 | |
1284 | 1284 | should 'use preferred domain for hostname' do |
1285 | - profile = Profile.new | |
1285 | + profile = Profile.new(:identifier => 'myself') | |
1286 | 1286 | profile.stubs(:preferred_domain).returns(Domain.new(:name => 'preferred.net')) |
1287 | 1287 | assert_equal 'preferred.net', profile.url[:host] |
1288 | + assert_equal 'myself', profile.url[:profile] | |
1288 | 1289 | end |
1289 | 1290 | |
1290 | 1291 | should 'provide a list of possible preferred domain names' do | ... | ... |