spec/integration/ripple/associations_spec.rb in ripple-0.9.0.beta2 vs spec/integration/ripple/associations_spec.rb in ripple-0.9.0

- old
+ new

@@ -56,9 +56,39 @@ @found.profile.name.should == 'Ripple' @found.profile.should be_a(Profile) @found.profile.user.should == @found end + it "should not raise an error when a one linked associated record has been deleted" do + @user.emergency_contact = @friend1 + @user.save + + @friend1.destroy + @found = User.find(@user.key) + @found.emergency_contact.should be_nil + end + + it "should allow a many linked record to be deleted from the association but kept in the datastore" do + @user.friends << @friend1 + @user.save! + + @user.friends.delete(@friend1) + @user.save! + + found_user = User.find(@user.key) + found_user.friends.should be_empty + User.find(@friend1.key).should be + end + + it "should allow a many embedded record to be deleted from the association" do + @user.addresses << @billing << @shipping + @user.save! + + @user.addresses.delete(@billing) + @user.save! + User.find(@user.key).addresses.should == [@shipping] + end + it "should save many embedded associations" do @user.addresses << @billing << @shipping @user.save @found = User.find(@user.key) @found.addresses.count.should == 2