forest_liana 8.0.3 → 8.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/forest_liana/associations_controller.rb +1 -1
- data/app/services/forest_liana/ability/permission.rb +2 -0
- data/app/services/forest_liana/has_many_dissociator.rb +4 -4
- data/lib/forest_liana/version.rb +1 -1
- data/spec/requests/actions_controller_spec.rb +33 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4b5358e0a8b103d87676b9f02ba9de7dbb35670f5a03f6dc4fd7f50d44f2424a
|
4
|
+
data.tar.gz: bf58dd7d9f38ba77f1bb6317f55179a6fb42babae5b6a5b56b9c282d2e0d79f3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0cfdec294649ddbfddf873de76ff961db3eeda40afa6a84ad679f71bddae9dd0fc16fd1d5d9992121ecfebcf335a73a11d95c893d9232b8a2e3f4fdecbb5c073
|
7
|
+
data.tar.gz: f30bb2f41054e24d88af4cf966fd7b836c4a227f1e053431769af623160ee734eacdc42e7f93d98fea729e97252b1860988e5b704fdaf0291ffa1226918c0751
|
@@ -30,6 +30,8 @@ module ForestLiana
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def is_smart_action_authorized?(user, collection, parameters, endpoint, http_method)
|
33
|
+
return true unless has_permission_system?
|
34
|
+
|
33
35
|
user_data = get_user_data(user['id'])
|
34
36
|
collections_data = get_collections_permissions_data
|
35
37
|
begin
|
@@ -1,11 +1,12 @@
|
|
1
1
|
module ForestLiana
|
2
|
-
class HasManyDissociator
|
3
|
-
def initialize(resource, association, params)
|
2
|
+
class HasManyDissociator
|
3
|
+
def initialize(resource, association, params, forest_user)
|
4
4
|
@resource = resource
|
5
5
|
@association = association
|
6
6
|
@params = params
|
7
7
|
@with_deletion = @params[:delete].to_s == 'true'
|
8
8
|
@data = params['data']
|
9
|
+
@forest_user = forest_user
|
9
10
|
end
|
10
11
|
|
11
12
|
def perform
|
@@ -13,11 +14,10 @@ module ForestLiana
|
|
13
14
|
associated_records = @resource.find(@params[:id]).send(@association.name)
|
14
15
|
|
15
16
|
remove_association = !@with_deletion || @association.macro == :has_and_belongs_to_many
|
16
|
-
|
17
17
|
if @data.is_a?(Array)
|
18
18
|
record_ids = @data.map { |record| record[:id] }
|
19
19
|
elsif @data.dig('attributes').present?
|
20
|
-
record_ids = ForestLiana::ResourcesGetter.get_ids_from_request(@params, forest_user)
|
20
|
+
record_ids = ForestLiana::ResourcesGetter.get_ids_from_request(@params, @forest_user)
|
21
21
|
else
|
22
22
|
record_ids = Array.new
|
23
23
|
end
|
data/lib/forest_liana/version.rb
CHANGED
@@ -312,6 +312,39 @@ describe 'Requesting Actions routes', :type => :request do
|
|
312
312
|
end
|
313
313
|
end
|
314
314
|
|
315
|
+
describe 'calling the action on development environment' do
|
316
|
+
let(:all_records) { false }
|
317
|
+
let(:params) {
|
318
|
+
{
|
319
|
+
data: {
|
320
|
+
attributes: {
|
321
|
+
collection_name: 'Island',
|
322
|
+
ids: ['1'],
|
323
|
+
all_records: all_records,
|
324
|
+
smart_action_id: 'Island-Test'
|
325
|
+
},
|
326
|
+
type: 'custom-action-requests'
|
327
|
+
},
|
328
|
+
timezone: 'Europe/Paris'
|
329
|
+
}
|
330
|
+
}
|
331
|
+
|
332
|
+
it 'should respond 200 and perform the action' do
|
333
|
+
Rails.cache.delete('forest.has_permission')
|
334
|
+
Rails.cache.delete('forest.users')
|
335
|
+
Rails.cache.write('forest.users', {'1' => { 'id' => 1, 'roleId' => 2, 'rendering_id' => '1' }})
|
336
|
+
allow_any_instance_of(ForestLiana::Ability::Fetch)
|
337
|
+
.to receive(:get_permissions)
|
338
|
+
.with('/liana/v4/permissions/environment')
|
339
|
+
.and_return(true)
|
340
|
+
|
341
|
+
post '/forest/actions/test', params: JSON.dump(params), headers: headers
|
342
|
+
|
343
|
+
expect(response.status).to eq(200)
|
344
|
+
expect(JSON.parse(response.body)).to eq({'success' => 'You are OK.'})
|
345
|
+
end
|
346
|
+
end
|
347
|
+
|
315
348
|
describe 'calling the action' do
|
316
349
|
before(:each) do
|
317
350
|
allow_any_instance_of(ForestLiana::Ability).to receive(:forest_authorize!) { true }
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: forest_liana
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 8.0.
|
4
|
+
version: 8.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sandro Munda
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-04
|
11
|
+
date: 2023-05-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|