forest_liana 8.3.0 → 8.3.1

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: 4ea6ac547b42d4f12e817252a87559007df62b18ab679d3ca7c6c3c5a4cd5e00
4
- data.tar.gz: 061b0e356dc3b0d3d3a83ee2b09760b20f13573b021abf7ed1cd0c9a4e810322
3
+ metadata.gz: f575399255a09d606c838be6a483b043c8b517eca0a8ccca55c747334555616b
4
+ data.tar.gz: fbe167b9daa4f6b3d22ddfd58e297cd3da3e020c165a548e37d8ae886c3671ed
5
5
  SHA512:
6
- metadata.gz: 67743e9e1cd9d3d1ce893b151b9069c5025d17fcdb763c936e699fd1cdf39b5b30392d0410bc9b77cb9a927bcda8b23755a59bee008928d4e6c73be0a2419710
7
- data.tar.gz: b74d7d94e51a29636935b751db6963a257f8f27e83e608b4a73b4a0fe6d4a459dbb3b27f602104b9a565da6f9a52f6ee699b278f052588d3f3cac09b3fb5b566
6
+ metadata.gz: 025fdca59a9d40cc79221d021f9f64b08aa95ad7cbb7035ee6f1adcc0350c00c7427cd80a25ddaebfe334c48ff83e92a30156709e1ac5a6e3701509b29bae5b9
7
+ data.tar.gz: 189a32d33adc6f1d898d10328032ae2a3a36da7dfd5be070bd555afba75869b6069ae306bee9d6b9215e55efb7354c11a42092c80811c7c0659fa5e2c021d161
@@ -97,7 +97,7 @@ module ForestLiana
97
97
  Rails.cache.fetch('forest.stats', expires_in: TTL) do
98
98
  stat_hash = []
99
99
  get_permissions('/liana/v4/permissions/renderings/' + rendering_id)['stats'].each do |stat|
100
- stat_hash << "#{stat['type']}:#{Digest::SHA1.hexdigest(stat.sort.to_h.to_s)}"
100
+ stat_hash << "#{stat['type']}:#{Digest::SHA1.hexdigest(stat.deep_sort.to_s)}"
101
101
  end
102
102
 
103
103
  stat_hash
@@ -1,3 +1,3 @@
1
1
  module ForestLiana
2
- VERSION = "8.3.0"
2
+ VERSION = "8.3.1"
3
3
  end
@@ -2,24 +2,8 @@ require 'rails_helper'
2
2
  require 'json'
3
3
 
4
4
  describe "Stats", type: :request do
5
-
6
- token = JWT.encode({
7
- id: 1,
8
- email: 'michael.kelso@that70.show',
9
- first_name: 'Michael',
10
- last_name: 'Kelso',
11
- team: 'Operations',
12
- rendering_id: '1',
13
- exp: Time.now.to_i + 2.weeks.to_i,
14
- permission_level: 'admin'
15
- }, ForestLiana.auth_secret, 'HS256')
16
-
17
- headers = {
18
- 'Accept' => 'application/json',
19
- 'Content-Type' => 'application/json',
20
- 'Authorization' => "Bearer #{token}"
21
- }
22
-
5
+ let(:rendering_id) { '13' }
6
+ let(:scopes) { {'scopes' => {}, 'team' => {'id' => '1', 'name' => 'Operations'}} }
23
7
  let(:schema) {
24
8
  [
25
9
  ForestLiana::Model::Collection.new({
@@ -30,10 +14,31 @@ describe "Stats", type: :request do
30
14
  ]
31
15
  }
32
16
 
17
+ let(:token) {
18
+ JWT.encode({
19
+ id: 1,
20
+ email: 'michael.kelso@that70.show',
21
+ first_name: 'Michael',
22
+ last_name: 'Kelso',
23
+ team: 'Operations',
24
+ rendering_id: rendering_id,
25
+ exp: Time.now.to_i + 2.weeks.to_i,
26
+ permission_level: 'user'
27
+ }, ForestLiana.auth_secret, 'HS256')
28
+ }
29
+
30
+ let(:headers) {
31
+ {
32
+ 'Accept' => 'application/json',
33
+ 'Content-Type' => 'application/json',
34
+ 'Authorization' => "Bearer #{token}"
35
+ }
36
+ }
37
+
33
38
  before do
34
39
  Rails.cache.write('forest.users', {'1' => { 'id' => 1, 'roleId' => 1, 'rendering_id' => '1' }})
35
40
  Rails.cache.write('forest.has_permission', true)
36
- allow_any_instance_of(ForestLiana::Ability::Fetch)
41
+ allow_any_instance_of(ForestLiana::Ability::Permission)
37
42
  .to receive(:get_permissions)
38
43
  .and_return(
39
44
  {
@@ -45,6 +50,31 @@ describe "Stats", type: :request do
45
50
  "aggregateFieldName" => nil,
46
51
  "sourceCollectionName" => "Owner"
47
52
  },
53
+ {
54
+ "type" => "Objective",
55
+ "sourceCollectionName" => "Owner",
56
+ "aggregateFieldName" => nil,
57
+ "aggregator" => "Count",
58
+ "objective" => 200,
59
+ "filter" => nil,
60
+ },
61
+ {
62
+ "type" => "Pie",
63
+ "sourceCollectionName" => "Owner",
64
+ "aggregateFieldName" => nil,
65
+ "groupByFieldName" => "id",
66
+ "aggregator" => "Count",
67
+ "filter" => nil,
68
+ },
69
+ {
70
+ "type" => "Line",
71
+ "sourceCollectionName" => "Owner",
72
+ "aggregateFieldName" => nil,
73
+ "groupByFieldName" => "hired_at",
74
+ "aggregator" => "Count",
75
+ "timeRange" => "Week",
76
+ "filter" => nil,
77
+ },
48
78
  {
49
79
  "type" => "Value",
50
80
  "query" => "SELECT COUNT(*) AS value FROM products;"
@@ -53,13 +83,9 @@ describe "Stats", type: :request do
53
83
  }
54
84
  )
55
85
 
56
- ForestLiana::ScopeManager.class_variable_set(:@@scopes_cache, {
57
- '1' => {
58
- :fetched_at => Time.now,
59
- :scopes => {}
60
- }
61
- })
62
-
86
+ ForestLiana::ScopeManager.invalidate_scope_cache(rendering_id)
87
+ allow(ForestLiana::ScopeManager).to receive(:fetch_scopes).and_return(scopes)
88
+
63
89
  allow(ForestLiana).to receive(:apimap).and_return(schema)
64
90
  allow(ForestLiana::IpWhitelist).to receive(:retrieve) { true }
65
91
  allow(ForestLiana::IpWhitelist).to receive(:is_ip_whitelist_retrieved) { 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.3.0
4
+ version: 8.3.1
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-03-14 00:00:00.000000000 Z
11
+ date: 2024-03-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails