forest_liana 9.3.7 → 9.3.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0fa0601f889d02cbdc81c73031621ae62ed6517e6a606e1d5b177f4d0315e357
4
- data.tar.gz: 8972e07871d08cf8a4254608d2ebfdd40a05612c031972e1b6b51f6f751a664a
3
+ metadata.gz: 103afe5988f7c2264d766f270e9fe94acabafd3dff2771616406d24235e178db
4
+ data.tar.gz: 351d284979c39cd903b40f74149bc71a8d4cfde44ec7a9e99f6e12a69a743229
5
5
  SHA512:
6
- metadata.gz: 94ae6c97585ecb0d68caee75c6196ef344455b4d88d26f2d1a9777439bd245a3bf17e1101b5d5879578cea6941da2c4113e50f72e2e302d59a464aae893d04b4
7
- data.tar.gz: 2d3d66dea8726e2351ab0f79290990b4ae6bec5b18ea6cc9e00f1a98b247eed3a21c25cf94d2ac8d9dac9ee05e3a1bcaff9d1536b1505ada8bfcf8c1df8843ff
6
+ metadata.gz: '099ff2ca0f05fd7ce0a27aa6935ed16ee856559096b0f750b30d30bf3a3c7ea94b6572fec0823381fb17fed5adc719915de86349876b9f861c1184c56ed367cb'
7
+ data.tar.gz: '08c6baba0689e84bb23c7535f9748c25fdabb31ec0ada34a5f61f8c05df3e39cd58038c84cc9279d84fbbcd3b2e85681b0404c555e39bd1fdc971309ff5674dd'
@@ -16,7 +16,8 @@ module ForestLiana
16
16
  collection_name = ForestLiana.name_for(collection)
17
17
 
18
18
  begin
19
- is_allowed = collections_data[collection_name][action].include? user_data['roleId']
19
+ is_allowed = (collections_data.key?(collection_name) && collections_data[collection_name][action].include?(user_data['roleId']))
20
+
20
21
  # re-fetch if user permission is not allowed (may have been changed)
21
22
  unless is_allowed
22
23
  collections_data = get_collections_permissions_data(true)
@@ -25,7 +26,7 @@ module ForestLiana
25
26
 
26
27
  is_allowed
27
28
  rescue
28
- raise ForestLiana::Errors::ExpectedError.new(409, :conflict, "The collection #{collection} doesn't exist", 'collection not found')
29
+ raise ForestLiana::Errors::ExpectedError.new(409, :conflict, "The collection #{collection_name} doesn't exist", 'collection not found')
29
30
  end
30
31
  end
31
32
 
@@ -1,3 +1,3 @@
1
1
  module ForestLiana
2
- VERSION = "9.3.7"
2
+ VERSION = "9.3.8"
3
3
  end
@@ -79,6 +79,7 @@ module ForestLiana
79
79
  end
80
80
  end
81
81
 
82
+
82
83
  it 'should throw an exception when the collection doesn\'t exist' do
83
84
  expect {dummy_class.is_crud_authorized?('browse', user, String)}.to raise_error(ForestLiana::Errors::ExpectedError, 'The collection String doesn\'t exist')
84
85
  end
@@ -163,6 +164,53 @@ module ForestLiana
163
164
  expect(dummy_class.is_crud_authorized?('browse', user, Island)).to equal true
164
165
  end
165
166
 
167
+ it 'should re-fetch the permission once when collection_name doesn\'t exist' do
168
+ Rails.cache.write(
169
+ 'forest.collections',
170
+ {
171
+ "collections" => {
172
+ "Fake_collection_name" => {
173
+ "collection" => {
174
+ "browseEnabled" => { "roles" => [1] },
175
+ "readEnabled" => { "roles" => [1] },
176
+ "editEnabled" => { "roles" => [1] },
177
+ "addEnabled" => { "roles" => [1] },
178
+ "deleteEnabled" => { "roles" => [1] },
179
+ "exportEnabled" => { "roles" => [1] }
180
+ },
181
+ "actions" => {
182
+
183
+ }
184
+ }
185
+ }
186
+ }
187
+ )
188
+
189
+ allow_any_instance_of(ForestLiana::Ability::Fetch)
190
+ .to receive(:get_permissions)
191
+ .and_return(
192
+ {
193
+ "collections" => {
194
+ "Island" => {
195
+ "collection" => {
196
+ "browseEnabled" => { "roles" => [1] },
197
+ "readEnabled" => { "roles" => [1] },
198
+ "editEnabled" => { "roles" => [1] },
199
+ "addEnabled" => { "roles" => [1] },
200
+ "deleteEnabled" => { "roles" => [1] },
201
+ "exportEnabled" => { "roles" => [1] }
202
+ },
203
+ "actions" => {
204
+
205
+ }
206
+ }
207
+ }
208
+ }
209
+ )
210
+
211
+ expect(dummy_class.is_crud_authorized?('browse', user, Island)).to equal true
212
+ end
213
+
166
214
  it 'should return false when user permission is not allowed' do
167
215
  Rails.cache.delete('forest.users')
168
216
 
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: 9.3.7
4
+ version: 9.3.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sandro Munda
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-06-07 00:00:00.000000000 Z
11
+ date: 2024-06-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails