Commit 49f77753a84c98ac28d0001e8d2df2da44ce764b

Authored by AntonioTerceiro
1 parent fbdc8a69

ActionItem8: providing access to homepage through profile



git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@417 3f533792-8f58-4932-b0fe-aaf55b0a4547
app/models/profile.rb
... ... @@ -65,6 +65,11 @@ class Profile < ActiveRecord::Base
65 65 find_tagged_with(term) + find_all_by_name(term)
66 66 end
67 67  
  68 + def homepage(reload = false)
  69 + @homepage = nil if reload
  70 + @homepage ||= Article.find_by_path(self.identifier)
  71 + end
  72 +
68 73 # Returns information about the profile's owner that was made public by
69 74 # him/her. The returned value must be an array in the followinf format:
70 75 #
... ...
test/unit/profile_test.rb
... ... @@ -53,6 +53,13 @@ class ProfileTest < Test::Unit::TestCase
53 53 assert_not_nil page
54 54 assert_equal 'New Profile', page.title
55 55 end
  56 +
  57 + def test_should_provide_access_to_homepage
  58 + profile = Profile.create!(:identifier => 'newprofile', :name => 'New Profile')
  59 + page = profile.homepage
  60 + assert_kind_of Article, page
  61 + assert_equal profile.identifier, page.slug
  62 + end
56 63  
57 64 def test_name_should_be_mandatory
58 65 p = Profile.new
... ...