authorizy 0.2.1 → 0.2.2

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
  SHA256:
3
- metadata.gz: d3025788b5adf8a466ed73bfc45f709612ad1b05de0e5e887a84c67c31cd5074
4
- data.tar.gz: 354c47240e842ecdd4afa112e95e02ef094f94dfcd17e9431d7dbe97ee580283
3
+ metadata.gz: 2d7006471814660a18a36666a304b2a8178d0e6c206c08b4c7d84f1bb0619214
4
+ data.tar.gz: 75484b0f5b9960632799937725244e38552e2ad90999ddb9390572cf1880f2e5
5
5
  SHA512:
6
- metadata.gz: a8a73b41a1b8ea247cd59114d9ddf857f7727efa4c780fd5b6fe17a8805aa86528061e7fa49ec2f32c9fe4a80bb0d05a70341d8176af302cb6e31da4bdce9403
7
- data.tar.gz: d9c32ae7a0b4a81742d3caa9879c69b7949cc86ecf104b4e79f7e642fa7b92efb5b4047993a38f2136e8b226dd5119046f5e5faed85134e5f249513c3fed72dc
6
+ metadata.gz: b2591d21df9e87ac0161c6a03327797350f93b9a230733a2597f9ec703cd853a7de62c3e0fc52c1f6e2fe16fbaabc2c1317ce3e93a5c83284283262b750be875
7
+ data.tar.gz: 4e2d661a5560bb7f2fd3aca9fb8846e147828bac74b3cea9bcfd803ac1a64a0a95de9d7b7a4a2019cc7ad31c41694ae73a21bd0fb770e9412f537dd406403816
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ # v0.2.2
2
+
3
+ ## Fixes
4
+
5
+ - When Cop returns anything different from `true` it is converted to `false`;
6
+
1
7
  # v0.2.1
2
8
 
3
9
  ## Fixes
@@ -16,7 +16,7 @@ module Authorizy
16
16
  session_permissions.any? { |tuple| route_match?(tuple) } ||
17
17
  user_permissions.any? { |tuple| route_match?(tuple) }
18
18
 
19
- return @cop.public_send(cop_controller) if @cop.respond_to?(cop_controller)
19
+ return @cop.public_send(cop_controller) == true if @cop.respond_to?(cop_controller)
20
20
 
21
21
  false
22
22
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Authorizy
4
- VERSION = '0.2.1'
4
+ VERSION = '0.2.2'
5
5
  end
@@ -85,6 +85,76 @@ RSpec.describe Authorizy::Core, '#access?' do
85
85
  expect(described_class.new(current_user, params, session, cop: cop).access?).to be(true)
86
86
  end
87
87
  end
88
+
89
+ context 'when cop return nil' do
90
+ let!(:cop) do
91
+ Class.new(Authorizy::BaseCop) do
92
+ def access?
93
+ false
94
+ end
95
+
96
+ def admin__controller
97
+ nil
98
+ end
99
+ end.new(current_user, params, session)
100
+ end
101
+
102
+ it 'is converted to false' do
103
+ expect(described_class.new(current_user, params, session, cop: cop).access?).to be(false)
104
+ end
105
+ end
106
+
107
+ context 'when cop return empty' do
108
+ let!(:cop) do
109
+ Class.new(Authorizy::BaseCop) do
110
+ def access?
111
+ false
112
+ end
113
+
114
+ def admin__controller
115
+ ''
116
+ end
117
+ end.new(current_user, params, session)
118
+ end
119
+
120
+ it 'is converted to false' do
121
+ expect(described_class.new(current_user, params, session, cop: cop).access?).to be(false)
122
+ end
123
+ end
124
+
125
+ context 'when cop return nothing' do
126
+ let!(:cop) do
127
+ Class.new(Authorizy::BaseCop) do
128
+ def access?
129
+ false
130
+ end
131
+
132
+ def admin__controller; end
133
+ end.new(current_user, params, session)
134
+ end
135
+
136
+ it 'is converted to false' do
137
+ expect(described_class.new(current_user, params, session, cop: cop).access?).to be(false)
138
+ end
139
+ end
140
+
141
+ context 'when cop return true as string' do
142
+ let!(:cop) do
143
+ Class.new(Authorizy::BaseCop) do
144
+ def access?
145
+ false
146
+ end
147
+
148
+ def admin__controller
149
+ 'true'
150
+ end
151
+ end.new(current_user, params, session)
152
+ end
153
+
154
+ it 'is converted to false' do
155
+ expect(described_class.new(current_user, params, session, cop: cop).access?).to be(false)
156
+ end
157
+ end
88
158
  end
89
159
 
90
160
  context 'when user has the controller permission but not action' do
@@ -9,23 +9,3 @@ RSpec.describe RSpec::Matchers, '#be_authorized' do
9
9
  ).squish
10
10
  end
11
11
  end
12
-
13
- # matcher.actual
14
- # matcher.actual_formatted
15
- # matcher.and
16
- # matcher.description
17
- # matcher.diffable?
18
- # matcher.does_not_match?
19
- # matcher.expected
20
- # matcher.expected_formatted
21
- # matcher.expects_call_stack_jump?
22
- # matcher.failure_message
23
- # matcher.failure_message_when_negated
24
- # matcher.match_unless_raises
25
- # matcher.matcher_name
26
- # matcher.matcher_name=
27
- # matcher.matches?
28
- # matcher.or
29
- # matcher.present_ivars
30
- # matcher.rescued_exception
31
- # matcher.supports_block_expectations?
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: authorizy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Washington Botelho
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-09-05 00:00:00.000000000 Z
11
+ date: 2021-09-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord