From 69bdfe7a7fdb4dffda3d58becbc1c4c2c2ffff22 Mon Sep 17 00:00:00 2001 From: Vlatka Pavisic Date: Tue, 7 Mar 2017 16:01:00 +0100 Subject: Refs #2693 : Test permissions sync --- spec/fixtures/users.json | 31 ++++++++++++++++++++++++++++--- spec/models/user_spec.rb | 12 ++++++++++-- 2 files changed, 38 insertions(+), 5 deletions(-) (limited to 'spec') diff --git a/spec/fixtures/users.json b/spec/fixtures/users.json index d5affc81b..f4236a29e 100644 --- a/spec/fixtures/users.json +++ b/spec/fixtures/users.json @@ -10,7 +10,10 @@ "locked_at": null, "profile": "Administrateur", "organization_name": "STIF", - "organization_code": "STIF" + "organization_code": "STIF", + "permissions": [ + "boiv:edit-offer" + ] }, { "id": 2, "username": "luc.donnet", @@ -23,7 +26,10 @@ "locked_at": null, "profile": "Administrateur", "organization_name": "STIF", - "organization_code": "STIF" + "organization_code": "STIF", + "permissions": [ + "boiv:edit-offer" + ] }, { "id": 3, "username": "alban.peignier", @@ -36,7 +42,10 @@ "locked_at": null, "profile": "Administrateur", "organization_name": "STIF", - "organization_code": "STIF" + "organization_code": "STIF", + "permissions": [ + "boiv:edit-offer" + ] }, { "id": 4, "username": "pierre.vabre", @@ -115,6 +124,22 @@ "profile": "Administrateur", "organization_name": "STIF", "organization_code": "STIF" +}, { + "id": 9, + "username": "vlatka.pavisic", + "email": "vlatka.pavisic@af83.com", + "firstname": "Vlatka", + "lastname": "Pavisic", + "phone_number": "+33601010101", + "created_at": "2016-09-05T12:34:03.756Z", + "updated_at": "2016-09-05T12:34:03.756Z", + "locked_at": null, + "profile": "Administrateur", + "organization_name": "STIF", + "organization_code": "STIF", + "permissions": [ + "boiv:edit-offer" + ] }, { "id": 10, "username": "john.doe", diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index bbeb0caf5..f56680fc0 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -81,7 +81,7 @@ describe User, :type => :model do it 'should create new users' do User.portail_sync - expect(User.count).to eq(11) + expect(User.count).to eq(12) expect(Organisation.count).to eq(3) end @@ -112,7 +112,15 @@ describe User, :type => :model do it 'should not create new user if username is already present' do create :user, username: 'alban.peignier' User.portail_sync - expect(User.count).to eq(11) + expect(User.count).to eq(12) + end + + context 'permissions' do + it 'should give edit permissions to user if user has "edit offer" permission in portail' do + User.portail_sync + expect(User.find_by(username: 'vlatka.pavisic').permissions).not_to be_empty + expect(User.find_by(username: 'pierre.vabre').permissions).to be_nil + end end end -- cgit v1.2.3