restrict 0.0.6 → 0.0.7

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0e119fe0a7f5a3b29548df9ff5d6f6bf77b490ab
4
- data.tar.gz: 34a0da6663e3113ec9fcd1dce4b1bdde1afc7ae2
3
+ metadata.gz: 68a4da331094fb87ec736fbd19bfd69789b49df3
4
+ data.tar.gz: 57abb1a0b4c96ef18c13783a5ae15ed0d8e59016
5
5
  SHA512:
6
- metadata.gz: b7d7b6b0e2da3fea9b62fffadd031b464956659a7123d6dbab3c7d66e9fb7a060aa8deef33327af5326ec922985560852a0b38827110fc607c2caee9a89c4c35
7
- data.tar.gz: 4dce49238f2706ac0930f2d7a59f859cff47cb61d2709422bb9072fe4b916676fb854d33ba25bbe6536afba23596186ab1542487b5227012d5bb5ab6d4b145b4
6
+ metadata.gz: 24aaef845f178c795be551c1de4efa38d8cd750041b98d401a1c124483fb85f3e62b75e53d25e799316f232434108211a60fdc851f1f5ab4362563544109eca2
7
+ data.tar.gz: c85ac99aea25f9a20d7d17def516b27d1702223cd5d14c05586868a2b22881555c149995b26c4c3b4512c331e3690e3021ddf18b9ee88187b94ae314d90590b0
@@ -1,3 +1,7 @@
1
+ [0.0.7] - 2014-08-25
2
+ * Breaking change part 2: restrict without action names will now implicitly restrict all actions
3
+ * :all_actions modifier is gone
4
+
1
5
  [0.0.6] - 2014-08-25
2
6
  * Breaking change: use :unless instead of :allow_if
3
7
 
data/README.md CHANGED
@@ -44,7 +44,7 @@ What that does:
44
44
  ### Restrict all actions
45
45
 
46
46
  ```ruby
47
- restrict :all_actions
47
+ restrict
48
48
  ```
49
49
 
50
50
  This one will apply to all actions on this controller. It takes the `unless` option as well.
@@ -58,10 +58,6 @@ Restrict.config.authentication_validation_method = :admin_session_exists?
58
58
 
59
59
  You may set the method that is used to figure out whether a user is signed in or not to whatever you like, however it's default is `:user_signed_in?` which is the most common (devise) method in use.
60
60
 
61
- ## Todo Ideas
62
-
63
- * restrict :all_actions, except: [:new], unless: 'dsfsdf'
64
-
65
61
  ## Contributing
66
62
 
67
63
  You know how this works and bonus points for feature branches!
@@ -3,10 +3,9 @@ module Restrict
3
3
  attr_accessor :actions, :unless
4
4
 
5
5
  def initialize(*args)
6
- options = args.extract_options!
7
- @unless = options[:unless]
8
- @actions = args
9
- actions.empty? and raise ArgumentError, "expected actions to restrict, but got #{actions.inspect}"
6
+ options = args.extract_options!
7
+ @unless = options[:unless]
8
+ @actions = args
10
9
  end
11
10
 
12
11
  def applies_to?(action)
@@ -16,7 +15,7 @@ module Restrict
16
15
  private
17
16
 
18
17
  def applies_to_all_actions?
19
- actions.include?(:all_actions)
18
+ actions.empty?
20
19
  end
21
20
 
22
21
  def applies_to_action?(name)
@@ -1,3 +1,3 @@
1
1
  module Restrict
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
@@ -65,7 +65,7 @@ describe Restrict::Gatekeeper do
65
65
 
66
66
  context 'with multiple restrictions' do
67
67
  before do
68
- controller.class.restrict :all_actions
68
+ controller.class.restrict
69
69
  controller.class.restrict :edit, unless: :falsy
70
70
  end
71
71
 
@@ -7,10 +7,6 @@ describe Restrict::Restriction do
7
7
  it 'knows about its actions' do
8
8
  expect(restriction.actions).to eq [:show, :edit]
9
9
  end
10
-
11
- it 'raises an error if no actions were given' do
12
- expect { Restrict::Restriction.new }.to raise_error(ArgumentError)
13
- end
14
10
  end
15
11
 
16
12
  describe '#applies_to?' do
@@ -26,8 +22,8 @@ describe Restrict::Restriction do
26
22
  expect(restriction).not_to be_applies_to(:index)
27
23
  end
28
24
 
29
- it 'returns true if it concerns :all_actions' do
30
- restriction = Restrict::Restriction.new(:all_actions)
25
+ it 'returns true if it concerns all actions' do
26
+ restriction = Restrict::Restriction.new
31
27
  expect(restriction).to be_applies_to(:foo)
32
28
  expect(restriction).to be_applies_to(:bar)
33
29
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: restrict
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Johannes Opper