Commit 8c31058b5dad1f78577cf08f5a485b9d0e5e3b0b

Authored by AntonioTerceiro
1 parent 3d6e53c7

ActionItem23: providing url for profile



git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@1140 3f533792-8f58-4932-b0fe-aaf55b0a4547
app/models/profile.rb
@@ -151,4 +151,9 @@ class Profile < ActiveRecord::Base @@ -151,4 +151,9 @@ class Profile < ActiveRecord::Base
151 self.kind_of?(Organization) 151 self.kind_of?(Organization)
152 end 152 end
153 153
  154 + include ActionController::UrlWriter
  155 + def url
  156 + url_for(:host => self.environment.default_hostname, :profile => self.identifier, :controller => 'content_viewer', :action => 'view_page', :page => [])
  157 + end
  158 +
154 end 159 end
test/unit/profile_test.rb
@@ -218,7 +218,12 @@ class ProfileTest < Test::Unit::TestCase @@ -218,7 +218,12 @@ class ProfileTest < Test::Unit::TestCase
218 end 218 end
219 219
220 should 'provide url to itself' do 220 should 'provide url to itself' do
221 - flunk 'pending' 221 + env = Environment.default
  222 + assert_equal 'colivre.net', env.default_hostname
  223 +
  224 + profile = Profile.create!(:name => "Test Profile", :identifier => 'testprofile', :environment_id => env.id)
  225 +
  226 + assert_equal 'http://colivre.net/testprofile', profile.url
222 end 227 end
223 228
224 private 229 private