aspect memberships are now dependant delete_all on contact
This commit is contained in:
parent
1e6bf9c80e
commit
ba779e18d6
3 changed files with 29 additions and 1 deletions
|
|
@ -9,7 +9,7 @@ class Contact < ActiveRecord::Base
|
||||||
belongs_to :person
|
belongs_to :person
|
||||||
validates_presence_of :person
|
validates_presence_of :person
|
||||||
|
|
||||||
has_many :aspect_memberships
|
has_many :aspect_memberships, :dependent => :delete_all
|
||||||
has_many :aspects, :through => :aspect_memberships
|
has_many :aspects, :through => :aspect_memberships
|
||||||
validate :not_contact_for_self
|
validate :not_contact_for_self
|
||||||
validates_uniqueness_of :person_id, :scope => :user_id
|
validates_uniqueness_of :person_id, :scope => :user_id
|
||||||
|
|
|
||||||
16
spec/intergration/contact_deleting_spec.rb
Normal file
16
spec/intergration/contact_deleting_spec.rb
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
# 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'
|
require 'spec_helper'
|
||||||
|
|
||||||
describe Contact do
|
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
|
describe 'validations' do
|
||||||
let(:contact){Contact.new}
|
let(:contact){Contact.new}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue