Commit 0a37bbeca66b118014a0e67f69fe5d3ff9bb88b3

Authored by Joenio Costa
Committed by Antonio Terceiro
1 parent e06ba228

ActionItem1145: why cannot update profile when email not filled

Showing 2 changed files with 11 additions and 0 deletions   Show diff stats
app/models/person.rb
... ... @@ -142,6 +142,8 @@ class Person < Profile
142 142 validates_presence_of :user_id
143 143 validates_uniqueness_of :user_id
144 144  
  145 + validates_associated :user
  146 +
145 147 def email
146 148 self.user.nil? ? nil : self.user.email
147 149 end
... ...
test/unit/person_test.rb
... ... @@ -565,4 +565,13 @@ class PersonTest < Test::Unit::TestCase
565 565 assert !Profile['testuser1'].add_friend(p2)
566 566 end
567 567  
  568 + should 'not raise exception when validates person without e-mail' do
  569 + person = create_user('testuser1').person
  570 + person.user.email = nil
  571 +
  572 + assert_nothing_raised ActiveRecord::RecordInvalid do
  573 + assert !person.save
  574 + end
  575 + end
  576 +
568 577 end
... ...