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 :pending_requests, :in => :pending_request_ids, :class_name => 'Request'
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

View file

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