the user destroy now deletes the aspects
This commit is contained in:
parent
73dfab8601
commit
e648042b15
2 changed files with 9 additions and 5 deletions
|
|
@ -52,11 +52,11 @@ class User
|
||||||
many :visible_people, :in => :visible_person_ids, :class_name => 'Person' # One of these needs to go
|
many :visible_people, :in => :visible_person_ids, :class_name => 'Person' # One of these needs to go
|
||||||
many :pending_requests, :in => :pending_request_ids, :class_name => 'Request'
|
many :pending_requests, :in => :pending_request_ids, :class_name => 'Request'
|
||||||
many :raw_visible_posts, :in => :visible_post_ids, :class_name => 'Post'
|
many :raw_visible_posts, :in => :visible_post_ids, :class_name => 'Post'
|
||||||
many :aspects, :class_name => 'Aspect'
|
many :aspects, :class_name => 'Aspect', :dependent => :destroy
|
||||||
|
|
||||||
after_create :seed_aspects
|
after_create :seed_aspects
|
||||||
|
|
||||||
before_destroy :unfriend_everyone, :remove_person
|
before_destroy :unfriend_everyone, :remove_person, :remove_all_aspects
|
||||||
|
|
||||||
def strip_username
|
def strip_username
|
||||||
if username.present?
|
if username.present?
|
||||||
|
|
@ -400,4 +400,8 @@ class User
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def remove_all_aspects
|
||||||
|
aspects.destroy_all
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -130,11 +130,11 @@ describe User do
|
||||||
|
|
||||||
|
|
||||||
it 'should remove all aspects' do
|
it 'should remove all aspects' do
|
||||||
pending "this should use :dependant => :destroy on the many assoc...but that screws this test suite..."
|
|
||||||
aspects = user.aspects
|
aspects = user.aspects
|
||||||
|
aspects.count.should > 0
|
||||||
user.destroy
|
user.destroy
|
||||||
proc { aspects.reload }.should raise_error /does not exist/
|
aspects.reload
|
||||||
|
aspects.count.should == 0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue