diff --git a/app/models/profile.rb b/app/models/profile.rb index fe5a610..03666f1 100644 --- a/app/models/profile.rb +++ b/app/models/profile.rb @@ -113,6 +113,14 @@ class Profile < ActiveRecord::Base nil end + # returns the contact email for this profile. By default returns the the + # e-mail of the owner user. + # + # Subclasses may -- and should -- override this method. + def contact_email + self.user ? self.user.email : nil + end + # gets recent documents in this profile. # # +limit+ is the maximum number of documents to be returned. It defaults to diff --git a/test/unit/profile_test.rb b/test/unit/profile_test.rb index a35d85e..cd020f7 100644 --- a/test/unit/profile_test.rb +++ b/test/unit/profile_test.rb @@ -145,7 +145,10 @@ class ProfileTest < Test::Unit::TestCase end should 'provide a contact_email method which returns a ... contact email address' do - flunk 'not implemented yet' + p = Profile.create!(:name => 'Profile for testing ', :identifier => 'profilefortesting') + assert_nil p.contact_email + p.user = User.new(:email => 'testprofile@example.com') + assert_equal 'testprofile@example.com', p.contact_email end private -- libgit2 0.21.2