cannie 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cannie/version.rb +1 -1
- data/spec/cannie/controller_extensions_spec.rb +46 -12
- 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: 6b94c55e9c803c675720227999d8ad2dd25fd28d
|
4
|
+
data.tar.gz: 0d8ca482c78937b9f4b8703d1dc0a71a99bb4d39
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7bb904c6afa19b0726dece42bb5a12268fa035bf8cd27a1747eb4c31e5c1e4c72b49255f69ff57b4719ae54a7f1f7ab0a2c988885d3b4d4c32905ec5ecd5f2e7
|
7
|
+
data.tar.gz: 5caa12f62cafe9d7b357528656ca9c427f02c9eadfb01ec19b396271d52064560094e46640de8305912ebd18e31c591edbcf39fbeae917629b012b8fd255c9dd
|
data/lib/cannie/version.rb
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
class TestController < ActionController::Base
|
4
|
-
check_permissions
|
5
|
-
|
6
4
|
def action
|
7
5
|
end
|
8
6
|
end
|
@@ -31,21 +29,57 @@ describe Cannie::ControllerExtensions do
|
|
31
29
|
end
|
32
30
|
|
33
31
|
describe '.check_permissions' do
|
34
|
-
|
35
|
-
|
36
|
-
|
32
|
+
describe 'without conditions' do
|
33
|
+
before do
|
34
|
+
TestController.class_eval do
|
35
|
+
check_permissions
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'raises exception if controller.permitted? evaluates to false' do
|
40
|
+
expect { after_filters.first.call(subject) }.to raise_error(Cannie::CheckPermissionsNotPerformed)
|
41
|
+
end
|
37
42
|
|
38
|
-
|
39
|
-
|
40
|
-
|
43
|
+
it 'does not raise exception if controller.permitted? evaluates to true' do
|
44
|
+
subject.stub(:permitted?).and_return(true)
|
45
|
+
expect { after_filters.first.call(subject) }.not_to raise_error
|
46
|
+
end
|
41
47
|
end
|
42
48
|
|
43
|
-
|
44
|
-
|
49
|
+
describe 'with if condition' do
|
50
|
+
before do
|
51
|
+
TestController.class_eval do
|
52
|
+
check_permissions if: ->{ self.var == true }
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'raises exception if :if block executed in controller scope returns true' do
|
57
|
+
TestController.stub(:var).and_return(true)
|
58
|
+
expect { after_filters.first.call(subject) }.to raise_error(Cannie::CheckPermissionsNotPerformed)
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'does not raise exception if :if block executed in controller scope returns false' do
|
62
|
+
TestController.stub(:var).and_return(false)
|
63
|
+
expect { after_filters.first.call(subject) }.to raise_error(Cannie::CheckPermissionsNotPerformed)
|
64
|
+
end
|
45
65
|
end
|
46
66
|
|
47
|
-
|
48
|
-
|
67
|
+
describe 'with unless condition' do
|
68
|
+
before do
|
69
|
+
TestController.class_eval do
|
70
|
+
check_permissions unless: ->{ self.var == true }
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
it 'raises exception if :unless block executed in controller scope returns false' do
|
75
|
+
TestController.stub(:var).and_return(true)
|
76
|
+
expect { after_filters.first.call(subject) }.to raise_error(Cannie::CheckPermissionsNotPerformed)
|
77
|
+
end
|
78
|
+
|
79
|
+
it 'does not raise exception if :unless block executed in controller scope returns false' do
|
80
|
+
TestController.stub(:var).and_return(false)
|
81
|
+
expect { after_filters.first.call(subject) }.to raise_error(Cannie::CheckPermissionsNotPerformed)
|
82
|
+
end
|
49
83
|
end
|
50
84
|
end
|
51
85
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cannie
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- hck
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-09-
|
11
|
+
date: 2013-09-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|