blob: dbf95a1205f425b5b443ad0ae1d73c7a117c3b90 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
require 'spec_helper'
describe User do
#it { should validate_uniqueness_of :email }
#it { should validate_presence_of :name }
describe "#destroy" do
let!(:organisation){Factory(:organisation)}
let!(:user){Factory(:user, :organisation => organisation)}
context "user's organisation contains many user" do
let!(:other_user){Factory(:user, :organisation => organisation)}
it "should destoy also user's organisation" do
user.destroy
Organisation.where(:name => organisation.name).exists?.should be_true
read_organisation = Organisation.where(:name => organisation.name).first
read_organisation.users.count.should == 1
read_organisation.users.first.should == other_user
end
end
end
end
|