forest_liana 9.5.2 → 9.5.4

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: 93e5e9bbc17d64a32b2d38ce4effa876d682c356dbf1d180eb5e0117db644604
4
- data.tar.gz: 52b8528c2d513cd0b906d8d69f7a163053976cdfc09fdb8484f83702354c2b23
3
+ metadata.gz: '01219141321710917e3b67dcd37db280425c4cf1620c491172c4bc7ab5616047'
4
+ data.tar.gz: 12f0c3ae8d97f28a82e70f38c93545f0bed346607c7301a63436077a3e95e858
5
5
  SHA512:
6
- metadata.gz: 40fd658783f4362c1ec6fd94224a160d31ee29277f87eee3bfc53223d91f4e7854be9ba6c0eecd645c39723c5e4338962fc70b785c53e0e527a9e687b8fc3660
7
- data.tar.gz: 2620e9af72ecf6c7cd596ac4d596c36b10477b3ee0091cacb1758c233e890b85719c5acdfe678fffdc2e41e6c07c501585ddb6f81cd65b597a8864cd58187d06
6
+ metadata.gz: 775dbe23c00ecd54bd64cde35a6efc3c40d72d1e873fa9e11d7077c830a1778001d6a90f4c4e9373dcd782e39d371b6673dab6b8f8e7a539a44b0bda49d14f78
7
+ data.tar.gz: 42441b9c0e1df5f8d760b0216982865ce1c6193452c9fd2677708b1c3171cd162dee9ae61365013a8bb4790998ff2f3cac2e3fe96dc80bd64ecfc6bd003b7ae5
@@ -49,20 +49,15 @@ module ForestLiana
49
49
  end
50
50
 
51
51
  def self.fetch_scopes(rendering_id)
52
- response = ForestLiana::ForestApiRequester.get("/liana/v4/permissions/renderings/#{rendering_id}")
53
-
54
- if response.is_a?(Net::HTTPOK)
55
- Rails.cache.fetch('forest.scopes.' + rendering_id.to_s, expires_in: @@scope_cache_expiration_delta) do
56
- data = {}
57
- parse_response = JSON.parse(response.body)
58
-
59
- data['scopes'] = decode_scope(parse_response['collections'])
60
- data['team'] = parse_response['team']
61
-
62
- data
63
- end
64
- else
65
- raise 'Unable to fetch scopes'
52
+ Rails.cache.fetch("forest.scopes.#{rendering_id}", expires_in: @@scope_cache_expiration_delta) do
53
+ response = ForestLiana::ForestApiRequester.get("/liana/v4/permissions/renderings/#{rendering_id}")
54
+ raise 'Unable to fetch scopes' unless response.is_a?(Net::HTTPOK)
55
+ parsed_response = JSON.parse(response.body)
56
+
57
+ {
58
+ 'scopes' => decode_scope(parsed_response['collections']),
59
+ 'team' => parsed_response['team']
60
+ }
66
61
  end
67
62
  end
68
63
 
@@ -1,3 +1,3 @@
1
1
  module ForestLiana
2
- VERSION = "9.5.2"
2
+ VERSION = "9.5.4"
3
3
  end
@@ -73,6 +73,14 @@ module ForestLiana
73
73
  'team' => {'id' => '1', 'name' => 'Operations'},
74
74
  })
75
75
  end
76
+
77
+ it 'calls the API only once, even with multiple fetch_scopes calls' do
78
+ described_class.fetch_scopes(rendering_id)
79
+ described_class.fetch_scopes(rendering_id)
80
+
81
+ expect(ForestLiana::ForestApiRequester).to have_received(:get).once
82
+ end
83
+
76
84
  end
77
85
 
78
86
  describe 'when scope contains dynamic values' do
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.5.2
4
+ version: 9.5.4
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-11-18 00:00:00.000000000 Z
11
+ date: 2024-12-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails