diff options
| -rw-r--r-- | spec/fixtures/users.json | 31 | ||||
| -rw-r--r-- | spec/models/user_spec.rb | 12 |
2 files changed, 38 insertions, 5 deletions
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", @@ -116,6 +125,22 @@ "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", "email": "john.doe@af83.com", 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 |
