Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

update version, explain Context in README

  • Loading branch information...
commit 8dfd0994cdb5192782c8b0bc6ebaf721dc37b506 1 parent 31a1d71
@dnagir authored
Showing with 22 additions and 2 deletions.
  1. +21 −1 README.md
  2. +1 −1  lib/allowy/version.rb
View
22 README.md
@@ -93,7 +93,7 @@ If you want to change the context in Rails then just override it in the controll
```ruby
class PagesController < ApplicationController
def allowy_context
- {realy: 'anything', can_be: 'here', event: params}
+ {realy: 'anything', can_be: 'here', even: params}
end
end
```
@@ -217,8 +217,28 @@ describe PagesController do
post(:create).should be_success
end
end
+
+```
+
+But if you don't want to stub the context because you access its `can?`, `cannot?` or `authorize!` methods
+(allwing permission delegation) then you can simply mix the `Allowy::Context` in:
+
+```ruby
+class ControllerLikeContext
+ include Alllowy::Context
+ attr_accessor :current_user
+
+ def initialize(user)
+ @current_user = user
+ end
+end
+
+# Then you can simply instantiate it to check the permissions:
+ControllerLikeContext.new(that_user).should be_able_to :edit, Blog
+ControllerLikeContext.new(this_user).should_not be_able_to :edit, Blog
```
+
# Development
View
2  lib/allowy/version.rb
@@ -1,3 +1,3 @@
module Allowy
- VERSION = "0.1.2"
+ VERSION = "0.1.3"
end
Please sign in to comment.
Something went wrong with that request. Please try again.