Commit 87eec62e185dd38c2949243f61300226816f8c56

Authored by AntonioTerceiro
1 parent 074a66ad

ActionItem96: every person needs an e-mail address



git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@615 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing 2 changed files with 15 additions and 0 deletions   Show diff stats
app/models/person.rb
... ... @@ -48,4 +48,8 @@ class Person < Profile
48 48 self.person_info ||= PersonInfo.new
49 49 self.person_info.person = self
50 50 end
  51 +
  52 + def email
  53 + self.user.nil? ? nil : self.user.email
  54 + end
51 55 end
... ...
test/unit/person_test.rb
... ... @@ -86,4 +86,15 @@ class PersonTest < Test::Unit::TestCase
86 86 assert p.has_permission?('edit_profile', e)
87 87 assert !p.has_permission?('destroy_profile', e)
88 88 end
  89 +
  90 + should 'get an email address from the associated user instance' do
  91 + p = User.create!(:login => 'jonh', :email => 'john@doe.org', :password => 'dhoe', :password_confirmation => 'dhoe').person
  92 + assert_equal 'john@doe.org', p.email
  93 + end
  94 +
  95 + should 'get no email address when there is no associated user' do
  96 + p = Person.new
  97 + assert_nil p.email
  98 + end
  99 +
89 100 end
... ...