forest_liana 6.6.0 → 7.0.0.beta.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/forest_liana/actions_controller.rb +44 -29
- data/app/controllers/forest_liana/application_controller.rb +2 -2
- data/app/controllers/forest_liana/associations_controller.rb +1 -1
- data/app/controllers/forest_liana/base_controller.rb +1 -1
- data/app/controllers/forest_liana/resources_controller.rb +7 -6
- data/app/serializers/forest_liana/intercom_attribute_serializer.rb +1 -1
- data/app/serializers/forest_liana/intercom_conversation_serializer.rb +1 -1
- data/app/serializers/forest_liana/mixpanel_event_serializer.rb +1 -1
- data/app/serializers/forest_liana/serializer_factory.rb +1 -1
- data/app/serializers/forest_liana/stat_serializer.rb +1 -1
- data/app/serializers/forest_liana/stripe_bank_account_serializer.rb +1 -1
- data/app/serializers/forest_liana/stripe_card_serializer.rb +1 -1
- data/app/serializers/forest_liana/stripe_invoice_serializer.rb +1 -1
- data/app/serializers/forest_liana/stripe_payment_serializer.rb +1 -1
- data/app/serializers/forest_liana/stripe_subscription_serializer.rb +1 -1
- data/app/services/forest_liana/apimap_sorter.rb +1 -0
- data/app/services/forest_liana/permissions_checker.rb +40 -34
- data/app/services/forest_liana/permissions_formatter.rb +1 -1
- data/app/services/forest_liana/permissions_getter.rb +1 -4
- data/app/services/forest_liana/smart_action_field_validator.rb +49 -0
- data/config/initializers/errors.rb +17 -0
- data/lib/forest_liana/bootstrapper.rb +2 -2
- data/lib/forest_liana/schema_file_updater.rb +8 -0
- data/lib/forest_liana/version.rb +1 -1
- data/spec/lib/forest_liana/schema_file_updater_spec.rb +94 -0
- data/spec/requests/actions_controller_spec.rb +22 -20
- data/spec/services/forest_liana/permissions_checker_acl_disabled_spec.rb +45 -69
- data/spec/services/forest_liana/permissions_checker_acl_enabled_spec.rb +39 -63
- data/spec/services/forest_liana/permissions_checker_live_queries_spec.rb +3 -3
- data/spec/services/forest_liana/permissions_formatter_spec.rb +11 -11
- data/spec/services/forest_liana/smart_action_field_validator_spec.rb +70 -0
- metadata +119 -117
- data/app/helpers/forest_liana/is_same_data_structure_helper.rb +0 -44
- data/spec/helpers/forest_liana/is_same_data_structure_helper_spec.rb +0 -87
@@ -1,44 +0,0 @@
|
|
1
|
-
require 'set'
|
2
|
-
|
3
|
-
module ForestLiana
|
4
|
-
module IsSameDataStructureHelper
|
5
|
-
class Analyser
|
6
|
-
def initialize(object, other, deep = 0)
|
7
|
-
@object = object
|
8
|
-
@other = other
|
9
|
-
@deep = deep
|
10
|
-
end
|
11
|
-
|
12
|
-
def are_objects(object, other)
|
13
|
-
object && other && object.is_a?(Hash) && other.is_a?(Hash)
|
14
|
-
end
|
15
|
-
|
16
|
-
def check_keys(object, other, step = 0)
|
17
|
-
unless are_objects(object, other)
|
18
|
-
return false
|
19
|
-
end
|
20
|
-
|
21
|
-
object_keys = object.keys
|
22
|
-
other_keys = other.keys
|
23
|
-
|
24
|
-
if object_keys.length != other_keys.length
|
25
|
-
return false
|
26
|
-
end
|
27
|
-
|
28
|
-
object_keys_set = object_keys.to_set
|
29
|
-
other_keys.each { |key|
|
30
|
-
if !object_keys_set.member?(key) || (step + 1 <= @deep && !check_keys(object[key], other[key], step + 1))
|
31
|
-
return false
|
32
|
-
end
|
33
|
-
}
|
34
|
-
|
35
|
-
return true
|
36
|
-
end
|
37
|
-
|
38
|
-
def perform
|
39
|
-
check_keys(@object, @other)
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
@@ -1,87 +0,0 @@
|
|
1
|
-
module ForestLiana
|
2
|
-
context 'IsSameDataStructure class' do
|
3
|
-
it 'should: be valid with simple data' do
|
4
|
-
object = {:a => 'a', :b => 'b'}
|
5
|
-
other = {:a => 'a', :b => 'b'}
|
6
|
-
result = IsSameDataStructureHelper::Analyser.new(object, other).perform
|
7
|
-
expect(result).to be true
|
8
|
-
end
|
9
|
-
|
10
|
-
it 'should: be invalid with simple data' do
|
11
|
-
object = {:a => 'a', :b => 'b'}
|
12
|
-
other = {:a => 'a', :c => 'c'}
|
13
|
-
result = IsSameDataStructureHelper::Analyser.new(object, other).perform
|
14
|
-
expect(result).to be false
|
15
|
-
end
|
16
|
-
|
17
|
-
it 'should: be invalid with not same hash' do
|
18
|
-
object = {:a => 'a', :b => 'b'}
|
19
|
-
other = {:a => 'a', :b => 'b', :c => 'c'}
|
20
|
-
result = IsSameDataStructureHelper::Analyser.new(object, other).perform
|
21
|
-
expect(result).to be false
|
22
|
-
end
|
23
|
-
|
24
|
-
it 'should: be invalid with nil' do
|
25
|
-
object = nil
|
26
|
-
other = {:a => 'a', :b => 'b', :c => 'c'}
|
27
|
-
result = IsSameDataStructureHelper::Analyser.new(object, other).perform
|
28
|
-
expect(result).to be false
|
29
|
-
end
|
30
|
-
|
31
|
-
it 'should: be invalid with not hash' do
|
32
|
-
object = nil
|
33
|
-
other = {:a => 'a', :b => 'b', :c => 'c'}
|
34
|
-
result = IsSameDataStructureHelper::Analyser.new(object, other).perform
|
35
|
-
expect(result).to be false
|
36
|
-
end
|
37
|
-
|
38
|
-
it 'should: be invalid with integer' do
|
39
|
-
object = 1
|
40
|
-
other = {:a => 'a', :b => 'b', :c => 'c'}
|
41
|
-
result = IsSameDataStructureHelper::Analyser.new(object, other).perform
|
42
|
-
expect(result).to be false
|
43
|
-
end
|
44
|
-
|
45
|
-
it 'should: be invalid with string' do
|
46
|
-
object = 'a'
|
47
|
-
other = {:a => 'a', :b => 'b', :c => 'c'}
|
48
|
-
result = IsSameDataStructureHelper::Analyser.new(object, other).perform
|
49
|
-
expect(result).to be false
|
50
|
-
end
|
51
|
-
|
52
|
-
it 'should: be valid with depth 1' do
|
53
|
-
object = {:a => {:c => 'c'}, :b => {:d => 'd'}}
|
54
|
-
other = {:a => {:c => 'c'}, :b => {:d => 'd'}}
|
55
|
-
result = IsSameDataStructureHelper::Analyser.new(object, other, 1).perform
|
56
|
-
expect(result).to be true
|
57
|
-
end
|
58
|
-
|
59
|
-
it 'should: be invalid with depth 1' do
|
60
|
-
object = {:a => {:c => 'c'}, :b => {:d => 'd'}}
|
61
|
-
other = {:a => {:c => 'c'}, :b => {:e => 'e'}}
|
62
|
-
result = IsSameDataStructureHelper::Analyser.new(object, other, 1).perform
|
63
|
-
expect(result).to be false
|
64
|
-
end
|
65
|
-
|
66
|
-
it 'should: be invalid with depth 1 and nil' do
|
67
|
-
object = {:a => {:c => 'c'}, :b => {:d => 'd'}}
|
68
|
-
other = {:a => {:c => 'c'}, :b => nil}
|
69
|
-
result = IsSameDataStructureHelper::Analyser.new(object, other, 1).perform
|
70
|
-
expect(result).to be false
|
71
|
-
end
|
72
|
-
|
73
|
-
it 'should: be invalid with depth 1 and integer' do
|
74
|
-
object = {:a => {:c => 'c'}, :b => {:d => 'd'}}
|
75
|
-
other = {:a => {:c => 'c'}, :b => 1}
|
76
|
-
result = IsSameDataStructureHelper::Analyser.new(object, other, 1).perform
|
77
|
-
expect(result).to be false
|
78
|
-
end
|
79
|
-
|
80
|
-
it 'should: be invalid with depth 1 and string' do
|
81
|
-
object = {:a => {:c => 'c'}, :b => {:d => 'd'}}
|
82
|
-
other = {:a => {:c => 'c'}, :b => 'b'}
|
83
|
-
result = IsSameDataStructureHelper::Analyser.new(object, other, 1).perform
|
84
|
-
expect(result).to be false
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|