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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 20b0f6d3ffeedaeacc9c4ae11762c861d74b664e
4
- data.tar.gz: 18f5003cc7ecaabd9e43fbedc23c9350e0e5921e
3
+ metadata.gz: 6b94c55e9c803c675720227999d8ad2dd25fd28d
4
+ data.tar.gz: 0d8ca482c78937b9f4b8703d1dc0a71a99bb4d39
5
5
  SHA512:
6
- metadata.gz: cf7e901d46c51c7e698fece777cf9e57c8730e2716fc60f0fb9c518bddcd3814a11905b28b96fec97ead5a26ff48fa7bf64283a6e1cd982213071526fe2f5362
7
- data.tar.gz: 00e301a82871ea5b5e668cc15b96c43e7af58e97cc45825bfd95e68a1344662bfce97d60b4f22425c33ba0dace67753564b33f7b9fb236e24b6b4ecac51dab09
6
+ metadata.gz: 7bb904c6afa19b0726dece42bb5a12268fa035bf8cd27a1747eb4c31e5c1e4c72b49255f69ff57b4719ae54a7f1f7ab0a2c988885d3b4d4c32905ec5ecd5f2e7
7
+ data.tar.gz: 5caa12f62cafe9d7b357528656ca9c427f02c9eadfb01ec19b396271d52064560094e46640de8305912ebd18e31c591edbcf39fbeae917629b012b8fd255c9dd
@@ -1,3 +1,3 @@
1
1
  module Cannie
2
- VERSION = '0.0.3'
2
+ VERSION = '0.0.4'
3
3
  end
@@ -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
- it 'raises exception if controller.permitted? evaluates to false' do
35
- expect { after_filters.first.call(subject) }.to raise_error(Cannie::CheckPermissionsNotPerformed)
36
- end
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
- it 'does not raise exception if controller.permitted? evaluates to true' do
39
- subject.stub(:permitted?).and_return(true)
40
- expect { after_filters.first.call(subject) }.not_to raise_error
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
- it 'raises exception if :if block executed in controller scope returns false' do
44
- pending
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
- it 'raises exception if :if block executed in controller scope returns true' do
48
- pending
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.3
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-13 00:00:00.000000000 Z
11
+ date: 2013-09-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler