Commit ba779e18 authored by zhitomirskiyi's avatar zhitomirskiyi

aspect memberships are now dependant delete_all on contact

parent 1e6bf9c8
......@@ -9,7 +9,7 @@ class Contact < ActiveRecord::Base
belongs_to :person
validates_presence_of :person
has_many :aspect_memberships
has_many :aspect_memberships, :dependent => :delete_all
has_many :aspects, :through => :aspect_memberships
validate :not_contact_for_self
validates_uniqueness_of :person_id, :scope => :user_id
......
# Copyright (c) 2010, Diaspora Inc. This file is
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
require 'spec_helper'
describe 'disconnecting a contact' do
it 'removes the aspect membership' do
@user = alice
@user2 = bob
lambda{
@user.disconnect(@user.contact_for(@user2.person))
}.should change(AspectMembership, :count).by(-1)
end
end
......@@ -5,6 +5,18 @@
require 'spec_helper'
describe Contact do
describe 'aspect_memberships' do
before do
@user = alice
@user2 = bob
end
it 'set to dependant delete_all' do
lambda{
@user.contact_for(@user2.person).destroy
}.should change(AspectMembership, :count).by(-1)
end
end
describe 'validations' do
let(:contact){Contact.new}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment