forest_liana 9.5.3 → 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: 331a5a4b04f74fad06fa9b8f9443e2a91c27685483fb1bba39bedb1b409c498c
4
- data.tar.gz: 055da277ebd38b2617dbc5b61a24dfb0b0bf474bb65fb8763d50ed694926122a
3
+ metadata.gz: '01219141321710917e3b67dcd37db280425c4cf1620c491172c4bc7ab5616047'
4
+ data.tar.gz: 12f0c3ae8d97f28a82e70f38c93545f0bed346607c7301a63436077a3e95e858
5
5
  SHA512:
6
- metadata.gz: 50c346b60aea696ed3295aa82c51cb92167e94c0a24168f039f1d673f2c9e48bed79b6699004d00b55e35bfb3b1ed55a0465c8f8b824256e645da831ca6b89cd
7
- data.tar.gz: aa3fd7c4133120ff50c0c88a4ab0b5873a6f5a28d1acd83b11a409a3557e15c0f8dbad572a43f44f39e1ba0d142f282a4a9a9ebf68e8496d7cd1425eedd0b5ed
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.3"
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.3
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-22 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