diff options
| author | Marc Florisson | 2012-08-24 11:46:09 +0200 | 
|---|---|---|
| committer | Marc Florisson | 2012-08-24 11:46:09 +0200 | 
| commit | 6fd69ca92e3090a2a8b7b73e7511bc1070290e22 (patch) | |
| tree | 8f25b31f44fe9b239b25d232f8aee8844c7d0688 /spec/models/user_spec.rb | |
| parent | 1fd4e99d38e25ba4e70324a2f06aa532ee0e7862 (diff) | |
| download | chouette-core-6fd69ca92e3090a2a8b7b73e7511bc1070290e22.tar.bz2 | |
create organisation
Diffstat (limited to 'spec/models/user_spec.rb')
| -rw-r--r-- | spec/models/user_spec.rb | 18 | 
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 | 
