aboutsummaryrefslogtreecommitdiffstats
path: root/spec/models
diff options
context:
space:
mode:
Diffstat (limited to 'spec/models')
-rw-r--r--spec/models/user_spec.rb19
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)}