Commit 89caaf771c08141a7a317fd8abed8750b9b09419
1 parent
356bfad3
Exists in
master
and in
29 other branches
ActionItem16: adding contact_email to Profile
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@811 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
2 changed files
with
12 additions
and
1 deletions
Show diff stats
app/models/profile.rb
@@ -113,6 +113,14 @@ class Profile < ActiveRecord::Base | @@ -113,6 +113,14 @@ class Profile < ActiveRecord::Base | ||
113 | nil | 113 | nil |
114 | end | 114 | end |
115 | 115 | ||
116 | + # returns the contact email for this profile. By default returns the the | ||
117 | + # e-mail of the owner user. | ||
118 | + # | ||
119 | + # Subclasses may -- and should -- override this method. | ||
120 | + def contact_email | ||
121 | + self.user ? self.user.email : nil | ||
122 | + end | ||
123 | + | ||
116 | # gets recent documents in this profile. | 124 | # gets recent documents in this profile. |
117 | # | 125 | # |
118 | # +limit+ is the maximum number of documents to be returned. It defaults to | 126 | # +limit+ is the maximum number of documents to be returned. It defaults to |
test/unit/profile_test.rb
@@ -145,7 +145,10 @@ class ProfileTest < Test::Unit::TestCase | @@ -145,7 +145,10 @@ class ProfileTest < Test::Unit::TestCase | ||
145 | end | 145 | end |
146 | 146 | ||
147 | should 'provide a contact_email method which returns a ... contact email address' do | 147 | should 'provide a contact_email method which returns a ... contact email address' do |
148 | - flunk 'not implemented yet' | 148 | + p = Profile.create!(:name => 'Profile for testing ', :identifier => 'profilefortesting') |
149 | + assert_nil p.contact_email | ||
150 | + p.user = User.new(:email => 'testprofile@example.com') | ||
151 | + assert_equal 'testprofile@example.com', p.contact_email | ||
149 | end | 152 | end |
150 | 153 | ||
151 | private | 154 | private |