aboutsummaryrefslogtreecommitdiffstats
path: root/spec/support/pundit
diff options
context:
space:
mode:
authorRobert2017-07-03 15:34:11 +0200
committerRobert2017-07-04 21:54:04 +0200
commitc48ad4fde3056ef04645b73f7eab54ff867d370c (patch)
tree57af273b48f1ece1b5e16244d6957f407a5d9563 /spec/support/pundit
parent747d333ffbcc8ee0c9f1daf93ccca32799434e04 (diff)
downloadchouette-core-c48ad4fde3056ef04645b73f7eab54ff867d370c.tar.bz2
Refs: #3478@1h
newapplication helper default authorization, (no if) -> * DefaultPolicy (all true) * Add some policies (LinePolicy) * Use `boiv:read` pour show, index * Adapted `table_builder`
Diffstat (limited to 'spec/support/pundit')
-rw-r--r--spec/support/pundit/policies.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/spec/support/pundit/policies.rb b/spec/support/pundit/policies.rb
index 02fea2944..d5bb63243 100644
--- a/spec/support/pundit/policies.rb
+++ b/spec/support/pundit/policies.rb
@@ -35,10 +35,24 @@ module Support
end
end
end
+
+ module FeaturePermissionMacros
+ def with_permissions(*permissions, &blk)
+ perms, options = permissions.partition{|x| String === x}
+ context "with permissions #{perms.inspect}...", *options do
+ before do
+ add_permissions(*permissions, for_user: @user)
+ end
+ instance_eval(&blk)
+ end
+ end
+ end
end
end
RSpec.configure do | c |
c.include Support::Pundit::Policies, type: :policy
c.extend Support::Pundit::PoliciesMacros, type: :policy
+ c.include Support::Pundit::Policies, type: :feature
+ c.extend Support::Pundit::FeaturePermissionMacros, type: :feature
end