aboutsummaryrefslogtreecommitdiffstats
path: root/spec/models/user_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/models/user_spec.rb')
-rw-r--r--spec/models/user_spec.rb18
1 files changed, 17 insertions, 1 deletions
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
index 44032b484..dbf95a120 100644
--- a/spec/models/user_spec.rb
+++ b/spec/models/user_spec.rb
@@ -1,5 +1,21 @@
require 'spec_helper'
describe User do
- pending "add some examples to (or delete) #{__FILE__}"
+ #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