acl9 1.3.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +18 -0
- data/Gemfile +2 -1
- data/Gemfile.lock +5 -1
- data/README.md +11 -1
- data/lib/acl9/controller_extensions/dsl_base.rb +5 -0
- data/lib/acl9/prepositions.rb +3 -3
- data/lib/acl9/version.rb +1 -1
- data/test/controller_extensions/prepositions_test.rb +9 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a8c381fe3a5d5c08f53de89f42e32a3d537c0194
|
4
|
+
data.tar.gz: 6f1ecac6cf51489c7ac811b1cf953b260c7b0e97
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 12dc684ca7c51688d5b19706ccde9c257e673212475ff31d897a403529879649a5381d7961aaab17a7e94b14bcbd483039aed942f053ab1aa716452c8560f0ff
|
7
|
+
data.tar.gz: af2e0997183914917e14239eb1268a803bad66bd7f0a35f9703a43431d84bf532671a32e2d22471e13a42af28daf32bac211f2cfe12a0cd861cfd520379e7479
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,21 @@
|
|
1
|
+
## 2.0.0 - 14 May 2015
|
2
|
+
|
3
|
+
Thanks to @pjungwir:
|
4
|
+
|
5
|
+
* Raise ArgumentError now if bad options passed to allow/deny
|
6
|
+
|
7
|
+
## 1.3.0 - 13 May 2015
|
8
|
+
|
9
|
+
Quick new feature dump:
|
10
|
+
|
11
|
+
* Prepositions in has(_no)_role[!?] methods
|
12
|
+
|
13
|
+
## 1.2.1 - 13 Mar 2015
|
14
|
+
|
15
|
+
Bugfix for API love:
|
16
|
+
|
17
|
+
* Rails::API was erroring
|
18
|
+
|
1
19
|
## 1.2.0 - 12 Jan 2015
|
2
20
|
|
3
21
|
The generator release (and some other cool new features):
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -42,15 +42,18 @@ GEM
|
|
42
42
|
minitest (~> 5.1)
|
43
43
|
thread_safe (~> 0.3, >= 0.3.4)
|
44
44
|
tzinfo (~> 1.1)
|
45
|
-
ansi (1.
|
45
|
+
ansi (1.5.0)
|
46
46
|
appraisal (1.0.2)
|
47
47
|
bundler
|
48
48
|
rake
|
49
49
|
thor (>= 0.14.0)
|
50
50
|
arel (6.0.0)
|
51
51
|
builder (3.2.2)
|
52
|
+
byebug (4.0.5)
|
53
|
+
columnize (= 0.9.0)
|
52
54
|
codeclimate-test-reporter (0.4.1)
|
53
55
|
simplecov (>= 0.7.1, < 1.0.0)
|
56
|
+
columnize (0.9.0)
|
54
57
|
docile (1.1.5)
|
55
58
|
erubis (2.7.0)
|
56
59
|
globalid (0.3.5)
|
@@ -128,6 +131,7 @@ PLATFORMS
|
|
128
131
|
DEPENDENCIES
|
129
132
|
acl9!
|
130
133
|
appraisal
|
134
|
+
byebug
|
131
135
|
codeclimate-test-reporter
|
132
136
|
minitap
|
133
137
|
sqlite3
|
data/README.md
CHANGED
@@ -16,7 +16,7 @@ Acl9 is [Semantically Versioned](http://semver.org/), so just add this to your
|
|
16
16
|
`Gemfile`:
|
17
17
|
|
18
18
|
```ruby
|
19
|
-
gem 'acl9', '~>
|
19
|
+
gem 'acl9', '~> 2.0'
|
20
20
|
```
|
21
21
|
|
22
22
|
You will need Ruby 2.x
|
@@ -277,6 +277,16 @@ end
|
|
277
277
|
|
278
278
|
**Then check for any duplicates** and resolve those manually.
|
279
279
|
|
280
|
+
### Acl9 now raises ArgumentError on bad args to `allow`/`deny`
|
281
|
+
|
282
|
+
In 2.x and above we now try to help the developer by raising ArgumentError if
|
283
|
+
they mess up with the options they pass to `allow`/`deny`, this prevents people
|
284
|
+
doing things that they think are going to work but actually aren't like:
|
285
|
+
|
286
|
+
```ruby
|
287
|
+
allow all, actions: [ :index, :show ] # <---- BROKEN!!
|
288
|
+
```
|
289
|
+
|
280
290
|
## Community
|
281
291
|
|
282
292
|
**IRC:** Please drop in for a chat on #acl9 on Freenode, [use
|
@@ -92,8 +92,13 @@ module Acl9
|
|
92
92
|
alias everybody all
|
93
93
|
alias anyone all
|
94
94
|
|
95
|
+
def _permitted_allow_deny_option!(key)
|
96
|
+
raise ArgumentError, "#{key} is not a valid option" unless [:to, :except, :if, :unless, *VALID_PREPOSITIONS].include?(key.to_sym)
|
97
|
+
end
|
98
|
+
|
95
99
|
def _parse_and_add_rule(*args)
|
96
100
|
options = args.extract_options!
|
101
|
+
options.keys.each { |key| _permitted_allow_deny_option!(key) }
|
97
102
|
|
98
103
|
_set_action_clause(options.delete(:to), options.delete(:except))
|
99
104
|
|
data/lib/acl9/prepositions.rb
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
module Acl9
|
2
2
|
module Prepositions
|
3
|
-
VALID_PREPOSITIONS = %
|
3
|
+
VALID_PREPOSITIONS = %i(of for in on at by).freeze unless defined? VALID_PREPOSITIONS
|
4
4
|
|
5
5
|
def _by_preposition options
|
6
6
|
object = nil
|
7
7
|
|
8
8
|
VALID_PREPOSITIONS.each do |prep|
|
9
|
-
if options[prep
|
9
|
+
if options[prep]
|
10
10
|
raise ArgumentError, "You may only use one preposition to specify object" if object
|
11
11
|
|
12
|
-
object = options[prep
|
12
|
+
object = options[prep]
|
13
13
|
end
|
14
14
|
end
|
15
15
|
object
|
data/lib/acl9/version.rb
CHANGED
@@ -28,6 +28,15 @@ module ControllerExtensions
|
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
|
+
test "invalid option raises ArgumentError" do
|
32
|
+
assert @foo = Foo.first_or_create
|
33
|
+
assert ( user = User.create).has_role! :manager, of: @foo
|
34
|
+
|
35
|
+
assert_raise ArgumentError do
|
36
|
+
@tester.acl_block! { allow :manager, of: :foo, something_bad: :foo }
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
31
40
|
test "allow class role allowed" do
|
32
41
|
assert ( user = User.create ).has_role! :owner, Foo
|
33
42
|
|