acl9 1.3.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c453f2d63455ec9792617d8436fdf11069dc843d
4
- data.tar.gz: 20ae0c3d277ac3b8393b5a63e04a2b4c3e8c2576
3
+ metadata.gz: a8c381fe3a5d5c08f53de89f42e32a3d537c0194
4
+ data.tar.gz: 6f1ecac6cf51489c7ac811b1cf953b260c7b0e97
5
5
  SHA512:
6
- metadata.gz: 3ea8427b7aac68a931a94c5cdefd3c5f82560130efd528bc46f260f55595044a4b425b3ee24bd22adf80a03b6fc57156142aee0d66b80b50703dcfae55245f0a
7
- data.tar.gz: 07e1e06046612cad72fcbb37b8070b5c76d554b6f5168aeaa5eeec733696e639cde81cea13fecb19d2f5440245dcf83d69330038c32b01d68839358118424f07
6
+ metadata.gz: 12dc684ca7c51688d5b19706ccde9c257e673212475ff31d897a403529879649a5381d7961aaab17a7e94b14bcbd483039aed942f053ab1aa716452c8560f0ff
7
+ data.tar.gz: af2e0997183914917e14239eb1268a803bad66bd7f0a35f9703a43431d84bf532671a32e2d22471e13a42af28daf32bac211f2cfe12a0cd861cfd520379e7479
@@ -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
@@ -1,8 +1,9 @@
1
1
  source "http://rubygems.org"
2
2
 
3
- # Specify your gem's dependencies in csvision.gemspec
3
+ # Specify your gem's dependencies in acl9.gemspec
4
4
  gemspec
5
5
 
6
6
  gem 'appraisal'
7
7
  gem 'tapout'
8
8
  gem 'minitap'
9
+ gem 'byebug'
@@ -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.4.3)
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', '~> 1.0'
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
 
@@ -1,15 +1,15 @@
1
1
  module Acl9
2
2
  module Prepositions
3
- VALID_PREPOSITIONS = %w(of for in on at by).freeze unless defined? 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.to_sym]
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.to_sym]
12
+ object = options[prep]
13
13
  end
14
14
  end
15
15
  object
@@ -1,3 +1,3 @@
1
1
  module Acl9
2
- VERSION = "1.3.0"
2
+ VERSION = "2.0.0"
3
3
  end
@@ -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
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acl9
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - oleg dashevskii