forest_liana 9.3.7 → 9.3.9

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: 0fa0601f889d02cbdc81c73031621ae62ed6517e6a606e1d5b177f4d0315e357
4
- data.tar.gz: 8972e07871d08cf8a4254608d2ebfdd40a05612c031972e1b6b51f6f751a664a
3
+ metadata.gz: 9420eb4b991fed9b8586d449be403e1e18233e4e9cfb49dd07af81fc34183b58
4
+ data.tar.gz: '018a7faf146dfc6aec02d14f12557c12add1b9236505c927117703c0c19a69ef'
5
5
  SHA512:
6
- metadata.gz: 94ae6c97585ecb0d68caee75c6196ef344455b4d88d26f2d1a9777439bd245a3bf17e1101b5d5879578cea6941da2c4113e50f72e2e302d59a464aae893d04b4
7
- data.tar.gz: 2d3d66dea8726e2351ab0f79290990b4ae6bec5b18ea6cc9e00f1a98b247eed3a21c25cf94d2ac8d9dac9ee05e3a1bcaff9d1536b1505ada8bfcf8c1df8843ff
6
+ metadata.gz: 93488f0f9c7f00a19dae8a41fa1c916232808876c0d76e4fa584f66316a7a19c5a445e5c69bb0fe4ce177a5776165973b804bef1fc8a72a69711434dcdd1e9a9
7
+ data.tar.gz: 43a4984883cbb093ffeb4371dd516d02b816a57284eaa1c44b459f50a3838139994ca07ae7bca3c0b0034195aac527c207970e354d407ce00212cb5d9a2633fb
@@ -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.9"
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.9
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