Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added should_be_allowed_to documentation

  • Loading branch information...
commit ae95c8a87ec2914872da728d403ef4ab0e93d2fb 1 parent 5dcdaa3
@stffn authored
Showing with 8 additions and 1 deletion.
  1. +8 −1 lib/declarative_authorization/maintenance.rb
View
9 lib/declarative_authorization/maintenance.rb
@@ -142,7 +142,13 @@ def assert_raise_with_user (user, *args, &block)
with_user(user, &block)
end
end
-
+
+ # Test helper to test authorization rules. E.g.
+ # with_user a_normal_user do
+ # should_not_be_allowed_to :update, :conferences
+ # should_not_be_allowed_to :read, an_unpublished_conference
+ # should_be_allowed_to :read, a_published_conference
+ # end
def should_be_allowed_to (privilege, object_or_context)
options = {}
options[object_or_context.is_a?(Symbol) ? :context : :object] = object_or_context
@@ -151,6 +157,7 @@ def should_be_allowed_to (privilege, object_or_context)
end
end
+ # See should_be_allowed_to
def should_not_be_allowed_to (privilege, object_or_context)
options = {}
options[object_or_context.is_a?(Symbol) ? :context : :object] = object_or_context
Please sign in to comment.
Something went wrong with that request. Please try again.