cul_omniauth 0.5.1 → 0.5.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/concerns/cul/omniauth/abilities.rb +10 -6
- data/lib/cul/omniauth/version.rb +1 -1
- data/spec/dummy/log/test.log +24 -0
- data/spec/lib/cul/omniauth/abilities_spec.rb +26 -0
- data/spec/spec_helper.rb +1 -0
- 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: bf19c3f3c7ecdf7bb405d29f7d2c593c190752ef
|
4
|
+
data.tar.gz: b67f3c701be26d95141e7c616346796f192c3886
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f28759221aae5a03b598b7d2c1a8df2da34471434d3991b7f84af6bf0a9930c1fa109a5a4ec9e7e5be1b75e97412070c3c81607f45cfc69f3acccdfa75771ff3
|
7
|
+
data.tar.gz: 340ee56f8116272c7937ad6c80ac7bc25b444aaa4f5b6ea94523a597a20cac77c10753dc8d54a40aa5e708825ef538e6be43bece722c88ecf06a4146aabfa58f
|
@@ -5,17 +5,21 @@ module Cul::Omniauth::Abilities
|
|
5
5
|
ARRAY = [].freeze
|
6
6
|
end
|
7
7
|
def initialize(user=nil, opts={})
|
8
|
-
@user = user || User.new
|
9
|
-
roles = opts[:roles] || Empty::HASH
|
10
8
|
if user
|
9
|
+
@user = user
|
10
|
+
opts = {user_id: user.uid}.merge(opts)
|
11
|
+
else
|
12
|
+
@user = User.new
|
13
|
+
end
|
14
|
+
roles = opts[:roles] || Empty::HASH
|
15
|
+
if @user
|
11
16
|
role_permissions = self.class.config.select do |role,config|
|
12
|
-
roles.include?(role) or user.role?(role)
|
17
|
+
roles.include?(role) or @user.role?(role)
|
13
18
|
end
|
14
|
-
role_permissions[:'*'] = self.class.config.fetch(:*,Empty::HASH)
|
15
|
-
opts = {user_id: user.uid}.merge(opts)
|
16
19
|
else
|
17
|
-
role_permissions = {
|
20
|
+
role_permissions = {}
|
18
21
|
end
|
22
|
+
role_permissions[:'*'] = self.class.config.fetch(:*,Empty::HASH)
|
19
23
|
role_permissions.each do |role, config|
|
20
24
|
config.fetch(:can,Empty::HASH).each do |action, conditions|
|
21
25
|
if conditions.blank?
|
data/lib/cul/omniauth/version.rb
CHANGED
data/spec/dummy/log/test.log
CHANGED
@@ -224,3 +224,27 @@ no persisted user for id {"uid"=>"foo", "extra"=>{}}
|
|
224
224
|
no persisted user for id {"uid"=>"foo", "extra"=>{}}
|
225
225
|
no persisted user for id {"uid"=>"foo", "extra"=>{}}
|
226
226
|
no persisted user for id {"uid"=>"foo", "extra"=>{}}
|
227
|
+
no persisted user for id {"uid"=>"foo", "extra"=>{}}
|
228
|
+
no persisted user for id {"uid"=>"foo", "extra"=>{}}
|
229
|
+
no persisted user for id {"uid"=>"foo", "extra"=>{}}
|
230
|
+
no persisted user for id {"uid"=>"foo", "extra"=>{}}
|
231
|
+
no persisted user for id {"uid"=>"foo", "extra"=>{}}
|
232
|
+
no persisted user for id {"uid"=>"foo", "extra"=>{}}
|
233
|
+
no persisted user for id {"uid"=>"foo", "extra"=>{}}
|
234
|
+
no persisted user for id {"uid"=>"foo", "extra"=>{}}
|
235
|
+
no persisted user for id {"uid"=>"foo", "extra"=>{}}
|
236
|
+
no persisted user for id {"uid"=>"foo", "extra"=>{}}
|
237
|
+
no persisted user for id {"uid"=>"foo", "extra"=>{}}
|
238
|
+
no persisted user for id {"uid"=>"foo", "extra"=>{}}
|
239
|
+
no persisted user for id {"uid"=>"foo", "extra"=>{}}
|
240
|
+
no persisted user for id {"uid"=>"foo", "extra"=>{}}
|
241
|
+
no persisted user for id {"uid"=>"foo", "extra"=>{}}
|
242
|
+
no persisted user for id {"uid"=>"foo", "extra"=>{}}
|
243
|
+
no persisted user for id {"uid"=>"foo", "extra"=>{}}
|
244
|
+
no persisted user for id {"uid"=>"foo", "extra"=>{}}
|
245
|
+
no persisted user for id {"uid"=>"foo", "extra"=>{}}
|
246
|
+
no persisted user for id {"uid"=>"foo", "extra"=>{}}
|
247
|
+
no persisted user for id {"uid"=>"foo", "extra"=>{}}
|
248
|
+
no persisted user for id {"uid"=>"foo", "extra"=>{}}
|
249
|
+
no persisted user for id {"uid"=>"foo", "extra"=>{}}
|
250
|
+
no persisted user for id {"uid"=>"foo", "extra"=>{}}
|
@@ -163,4 +163,30 @@ describe Cul::Omniauth::Abilities do
|
|
163
163
|
end
|
164
164
|
end
|
165
165
|
end
|
166
|
+
|
167
|
+
context "with no user" do
|
168
|
+
let(:current_user) { nil }
|
169
|
+
let(:rules) do
|
170
|
+
YAML.load(fixture('test/role_config/members.yml').read)['_all_environments']
|
171
|
+
end
|
172
|
+
before do
|
173
|
+
Ability.instance_variable_set :@role_proxy_config, symbolize_hash_keys(rules)
|
174
|
+
rig.instance_variable_set :@current_ability, nil
|
175
|
+
end
|
176
|
+
after do
|
177
|
+
Ability.instance_variable_set :@role_proxy_config, nil
|
178
|
+
end
|
179
|
+
subject do
|
180
|
+
rig.current_ability
|
181
|
+
end
|
182
|
+
it "has abilities of *" do
|
183
|
+
expect(subject.can? :index, proxy).to be
|
184
|
+
end
|
185
|
+
it "has abilities of roles with member *" do
|
186
|
+
expect(subject.can? :download, proxy).to be
|
187
|
+
end
|
188
|
+
it "doesn't have unexpected abilities" do
|
189
|
+
expect(subject.can? :update, proxy).not_to be
|
190
|
+
end
|
191
|
+
end
|
166
192
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cul_omniauth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- barmintor
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-10-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|