diff --git a/app/models/profile.rb b/app/models/profile.rb index 3803e99..e8774f6 100644 --- a/app/models/profile.rb +++ b/app/models/profile.rb @@ -65,6 +65,11 @@ class Profile < ActiveRecord::Base find_tagged_with(term) + find_all_by_name(term) end + def homepage(reload = false) + @homepage = nil if reload + @homepage ||= Article.find_by_path(self.identifier) + end + # Returns information about the profile's owner that was made public by # him/her. The returned value must be an array in the followinf format: # diff --git a/test/unit/profile_test.rb b/test/unit/profile_test.rb index 301d3d9..a3768cf 100644 --- a/test/unit/profile_test.rb +++ b/test/unit/profile_test.rb @@ -53,6 +53,13 @@ class ProfileTest < Test::Unit::TestCase assert_not_nil page assert_equal 'New Profile', page.title end + + def test_should_provide_access_to_homepage + profile = Profile.create!(:identifier => 'newprofile', :name => 'New Profile') + page = profile.homepage + assert_kind_of Article, page + assert_equal profile.identifier, page.slug + end def test_name_should_be_mandatory p = Profile.new -- libgit2 0.21.2