Commit 0a37bbeca66b118014a0e67f69fe5d3ff9bb88b3
Committed by
Antonio Terceiro
1 parent
e06ba228
Exists in
master
and in
29 other branches
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,6 +142,8 @@ class Person < Profile | ||
142 | validates_presence_of :user_id | 142 | validates_presence_of :user_id |
143 | validates_uniqueness_of :user_id | 143 | validates_uniqueness_of :user_id |
144 | 144 | ||
145 | + validates_associated :user | ||
146 | + | ||
145 | def email | 147 | def email |
146 | self.user.nil? ? nil : self.user.email | 148 | self.user.nil? ? nil : self.user.email |
147 | end | 149 | end |
test/unit/person_test.rb
@@ -565,4 +565,13 @@ class PersonTest < Test::Unit::TestCase | @@ -565,4 +565,13 @@ class PersonTest < Test::Unit::TestCase | ||
565 | assert !Profile['testuser1'].add_friend(p2) | 565 | assert !Profile['testuser1'].add_friend(p2) |
566 | end | 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 | end | 577 | end |