diff options
| author | Vlatka Pavisic | 2017-01-13 17:37:52 +0100 | 
|---|---|---|
| committer | Vlatka Pavisic | 2017-01-13 17:37:52 +0100 | 
| commit | e36b449f7792da677f6aa74641e591fb66972ff6 (patch) | |
| tree | f9dfdfb79960290d1b741e8a3f0ed242b1f8a113 /spec | |
| parent | b0f53db2facca6ae040d70ff1d041847e566dc2f (diff) | |
| download | chouette-core-e36b449f7792da677f6aa74641e591fb66972ff6.tar.bz2 | |
Refs #2398 : Add permissions to User
Diffstat (limited to 'spec')
| -rw-r--r-- | spec/models/user_spec.rb | 19 | 
1 files changed, 18 insertions, 1 deletions
| diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 7d0a548c1..bbeb0caf5 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -13,7 +13,8 @@ describe User, :type => :model do            :email             => 'john.doe@af83.com',            :organisation_code => '0083',            :organisation_name => 'af83', -          :functional_scope  => "[\"STIF:CODIFLIGNE:Line:C00840\", \"STIF:CODIFLIGNE:Line:C00086\"]" +          :functional_scope  => "[\"STIF:CODIFLIGNE:Line:C00840\", \"STIF:CODIFLIGNE:Line:C00086\"]", +          :permissions       => nil          }          ticket.user    = "john.doe"          ticket.success = true @@ -115,6 +116,22 @@ describe User, :type => :model do      end    end +  describe 'validations' do +    it 'validates uniqueness of pemissions' do +      user = build :user, permissions: Array.new(2, 'calendars.shared') +      expect { +        user.save! +      }.to raise_error(ActiveRecord::RecordInvalid) +    end + +    it 'validates no pemission is an empty string' do +      user = build :user, permissions: [''] +      expect { +        user.save! +      }.to raise_error(ActiveRecord::RecordInvalid) +    end +  end +    describe "#destroy" do      let!(:organisation){create(:organisation)}      let!(:user){create(:user, :organisation => organisation)} | 
