diff options
| author | Robert | 2017-07-10 21:06:07 +0200 |
|---|---|---|
| committer | Robert | 2017-07-10 21:06:07 +0200 |
| commit | 1ab9c3364ffcd777dae39bd9154dca031cc00db0 (patch) | |
| tree | 1df7737a3b03f8b58c36e032301de4aad9c31871 /spec/support | |
| parent | 4c7f03108350bf540b6346f864b1ba022119507f (diff) | |
| download | chouette-core-1ab9c3364ffcd777dae39bd9154dca031cc00db0.tar.bz2 | |
Refs: #4021@0.15h; Fixes Policy Tests
Diffstat (limited to 'spec/support')
| -rw-r--r-- | spec/support/pundit/shared_examples.rb | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/spec/support/pundit/shared_examples.rb b/spec/support/pundit/shared_examples.rb index b91caa479..63a106759 100644 --- a/spec/support/pundit/shared_examples.rb +++ b/spec/support/pundit/shared_examples.rb @@ -64,7 +64,7 @@ RSpec.shared_examples 'always forbidden' do end end end -j + RSpec.shared_examples 'permitted policy and same organisation' do | permission, archived: false| @@ -101,3 +101,31 @@ RSpec.shared_examples 'permitted policy and same organisation' do end end end + +RSpec.shared_examples 'permitted policy' do + | permission, archived: false| + + context 'permission absent → ' do + it "denies user" do + expect_it.not_to permit(user_context, record) + end + end + + context 'permission present → ' do + before do + add_permissions(permission, for_user: user) + end + + it 'allows user' do + expect_it.to permit(user_context, record) + end + + if archived + it 'removes the permission for archived referentials' do + user.organisation_id = referential.organisation_id + referential.archived_at = 42.seconds.ago + expect_it.not_to permit(user_context, record) + end + end + end +end |
