access-granted 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -1
- data/access-granted.gemspec +1 -1
- data/lib/access-granted/permission.rb +1 -1
- data/spec/permission_spec.rb +6 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 246a35a6a2cb45ef63cc43536becfb22c88387a5
|
4
|
+
data.tar.gz: aae201ebfddf0b130961b0ca675863f32cc276ac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3b8277e5bf9ad6fdd843d572c0ef707b6e4c28c7bcc4e3dd4178037320ba8bae2b58566865dfff19c4853f01e8034f4512d83321d85ecc087ca79e8d68d4d79b
|
7
|
+
data.tar.gz: b477974a51014c347694dd2f4000936faa2ad4f595bcab22e3dbd8e56ab5cc40f08ddeec1978241ccf66e6899680f4948435530fe5daee185a5185b6e8e3f0cd
|
data/README.md
CHANGED
@@ -48,6 +48,8 @@ Roles are defined using blocks (or by passing custom classes to keep things tidy
|
|
48
48
|
**Order of the roles is VERY important**, because they are being traversed in the top-to-bottom order.
|
49
49
|
At the top you must have an admin or other important role giving the user top permissions, and as you go down you define less-privileged roles.
|
50
50
|
|
51
|
+
**I recommend starting your adventure by reading my [blog post about AccessGranted](http://blog.chaps.io/2015/11/13/role-based-authorization-in-rails.html), where I demonstrate its abilities on a real life example.**
|
52
|
+
|
51
53
|
### 1. Defining access policy
|
52
54
|
|
53
55
|
Let's start with a complete example of what can be achieved:
|
@@ -224,7 +226,7 @@ end
|
|
224
226
|
Usually you don't want to show "Create" buttons for people who can't create something.
|
225
227
|
You can hide any part of the page from users without permissions like this:
|
226
228
|
|
227
|
-
```
|
229
|
+
```erb
|
228
230
|
# app/views/categories/index.html.erb
|
229
231
|
|
230
232
|
<% if can? :create, Category %>
|
data/access-granted.gemspec
CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = "access-granted"
|
7
|
-
spec.version = "1.0.
|
7
|
+
spec.version = "1.0.3"
|
8
8
|
spec.authors = ["Piotrek Okoński"]
|
9
9
|
spec.email = ["piotrek@okonski.org"]
|
10
10
|
spec.description = %q{Role based authorization gem}
|
data/spec/permission_spec.rb
CHANGED
@@ -14,6 +14,12 @@ describe AccessGranted::Permission do
|
|
14
14
|
perm = subject.new(true, :read, sub.class, nil, {}, proc {|el| el.published? })
|
15
15
|
expect(perm.matches_conditions?(sub)).to eq(true)
|
16
16
|
end
|
17
|
+
|
18
|
+
it "does not match proc conditions when given a class instead of an instance" do
|
19
|
+
sub = double("Element", published?: true)
|
20
|
+
perm = subject.new(true, :read, sub.class, nil, {}, proc {|el| el.published? })
|
21
|
+
expect(perm.matches_conditions?(sub.class)).to eq(true)
|
22
|
+
end
|
17
23
|
end
|
18
24
|
|
19
25
|
describe "#matches_hash_conditions?" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: access-granted
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Piotrek Okoński
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-11-
|
11
|
+
date: 2015-11-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|