rddd 0.1.6 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -31,13 +31,13 @@ module Rddd
31
31
  # Create new rule applied to specified action and perform the given
32
32
  # block.
33
33
  #
34
- # @param {Symbol} Action the rule applies to.
34
+ # @param {Symbol | Array} Action the rule applies to.
35
35
  # @param {Block} Block to be executed to evaluate authorization.
36
36
  #
37
37
  def can(action, &block)
38
+ actions = action.kind_of?(Array) ? action : [action]
38
39
  @rules ||= []
39
-
40
- @rules << Rule.new(action, &block)
40
+ @rules.concat actions.map { |action| Rule.new(action, &block) }
41
41
  end
42
42
  end
43
43
  end
@@ -1,3 +1,3 @@
1
1
  module Rddd
2
- VERSION = "0.1.6"
2
+ VERSION = "0.1.7"
3
3
  end
@@ -17,13 +17,25 @@ describe Rddd::Authorization::RulesBuilder do
17
17
 
18
18
  let(:block) { lambda{|user, params| } }
19
19
 
20
- before do
21
- Rddd::Authorization::Rule.expects(:new).returns(rule)
20
+ context 'one rule' do
21
+ before do
22
+ Rddd::Authorization::Rule.expects(:new).returns(rule)
22
23
 
23
- builder.can(:foo, &block)
24
+ builder.can(:foo, &block)
25
+ end
26
+
27
+ its(:first) { should be rule }
24
28
  end
25
29
 
26
- its(:first) { should be rule }
30
+ context 'double rule' do
31
+ before do
32
+ Rddd::Authorization::Rule.expects(:new).twice.returns(rule)
33
+
34
+ builder.can([:foo, :bar], &block)
35
+ end
36
+
37
+ its(:size) { should eql 2 }
38
+ end
27
39
  end
28
40
 
29
41
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rddd
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: