MS IZ dependant destroy is back for aspects

This commit is contained in:
ilya 2010-10-20 11:47:09 -07:00
parent 992bd42b55
commit e6de6179e9
2 changed files with 15 additions and 19 deletions

View file

@ -60,7 +60,7 @@ 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

View file

@ -46,47 +46,43 @@ describe Aspect do
describe 'validation' do describe 'validation' do
before do before do
@aspect = user.aspect(:name => 'losers') aspect
end end
it 'has a unique name for one user' do it 'has a unique name for one user' do
aspect2 = user.aspect(:name => @aspect.name) aspect2 = user.aspect(:name => aspect.name)
aspect2.valid?.should be_false aspect2.valid?.should be_false
end end
it 'has no uniqueness between users' do it 'has no uniqueness between users' do
aspect2 = user2.aspect(:name => @aspect.name) aspect2 = user2.aspect(:name => aspect.name)
aspect2.valid?.should be_true aspect2.valid?.should be_true
end end
end end
describe 'querying' do describe 'querying' do
before do before do
@aspect = user.aspect(:name => 'losers') aspect
user.activate_friend(friend, @aspect) user.activate_friend(friend, aspect)
@aspect2 = user2.aspect(:name => 'failures') aspect2
friend_users(user, @aspect, user2, @aspect2) friend_users(user, aspect, user2, aspect2)
@aspect.reload aspect.reload
user.reload
end end
it 'belong to a user' do it 'belong to a user' do
<<<<<<< HEAD aspect.user.id.should == user.id
@aspect.user.id.should == user.id user.aspects.should == [aspect]
user.aspects.size.should == 3
=======
@aspect.user.id.should == @user.id
@user.aspects.size.should == 1
>>>>>>> 961510a8ed06590109a8090686355ffdcde71180
end end
it 'should have people' do it 'should have people' do
@aspect.people.all.include?(friend).should be true aspect.people.all.include?(friend).should be true
@aspect.people.size.should == 2 aspect.people.size.should == 2
end end
it 'should be accessible through the user' do it 'should be accessible through the user' do
aspects = user.aspects_with_person(friend) aspects = user.aspects_with_person(friend)
aspects.size.should == 1 aspects.size.should == 1
aspects.first.id.should == @aspect.id aspects.first.id.should == aspect.id
aspects.first.people.size.should == 2 aspects.first.people.size.should == 2
aspects.first.people.include?(friend).should be true aspects.first.people.include?(friend).should be true
aspects.first.people.include?(user2.person).should be true aspects.first.people.include?(user2.person).should be true