forest_liana 9.5.7 → 9.6.0
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bdddfd71dbc4f9c5ddab069162d5b0ba65c057c6f9e25cda811259e72e1daaa8
|
4
|
+
data.tar.gz: 8213f378007db1ac2663b3143c0e8cc5ca35a63e603c8fb81b2c4bdbbcb7d270
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1f805f7d8604f9db01bb69a41d6a70d0b30d1baa4897e12cf4d16d2805c915d272cf197111d8102c7d1f543efbd34490399d8d86144840c615b1a02a2cc03e36
|
7
|
+
data.tar.gz: 257e946211ad7b126c99ef5f75e45f2f5e8e073b9c4996294ac1d3fcce1da7fbaa4db06d52284ead53072b3c7585d72a4cc1d7b2a7a3a61f5dfe0c37325c7ca6
|
@@ -80,8 +80,16 @@ module ForestLiana::Collection
|
|
80
80
|
|
81
81
|
field = opts.merge({
|
82
82
|
field: name,
|
83
|
-
is_filterable:
|
84
|
-
|
83
|
+
is_filterable: if opts.has_key?(:is_filterable)
|
84
|
+
!!opts[:is_filterable]
|
85
|
+
else
|
86
|
+
!!opts[:polymorphic_key]
|
87
|
+
end,
|
88
|
+
is_sortable: if opts.has_key?(:is_sortable)
|
89
|
+
!!opts[:is_sortable]
|
90
|
+
else
|
91
|
+
!!opts[:polymorphic_key]
|
92
|
+
end
|
85
93
|
})
|
86
94
|
|
87
95
|
add_field(field)
|
data/lib/forest_liana/version.rb
CHANGED
@@ -0,0 +1,17 @@
|
|
1
|
+
class Forest::Address
|
2
|
+
include ForestLiana::Collection
|
3
|
+
|
4
|
+
collection :Address
|
5
|
+
|
6
|
+
field :addressable_type, type: 'String', polymorphic_key: true, is_filterable: false do
|
7
|
+
object.addressable_type
|
8
|
+
end
|
9
|
+
|
10
|
+
field :addressable_id, type: 'String', polymorphic_key: true do
|
11
|
+
object.addressable_type
|
12
|
+
end
|
13
|
+
|
14
|
+
field :address_type, type: 'String' do
|
15
|
+
'delivery'
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module ForestLiana
|
2
|
+
describe Collection do
|
3
|
+
before do
|
4
|
+
allow(ForestLiana).to receive(:env_secret).and_return(nil)
|
5
|
+
end
|
6
|
+
|
7
|
+
let(:collection) { ForestLiana.apimap.select { |collection| collection.name == 'Address' }.first }
|
8
|
+
|
9
|
+
describe 'field' do
|
10
|
+
it 'add simple smart field' do
|
11
|
+
field = collection.fields.select { |field| field[:field] == :address_type }.first
|
12
|
+
|
13
|
+
expect(field).not_to be_nil
|
14
|
+
expect(field).to eq(
|
15
|
+
{
|
16
|
+
type: "String",
|
17
|
+
is_read_only: true,
|
18
|
+
is_required: false,
|
19
|
+
default_value: nil,
|
20
|
+
integration: nil,
|
21
|
+
reference: nil,
|
22
|
+
inverse_of: nil,
|
23
|
+
relationships: nil,
|
24
|
+
widget: nil,
|
25
|
+
validations: [],
|
26
|
+
is_virtual: true,
|
27
|
+
field: :address_type,
|
28
|
+
is_filterable: false,
|
29
|
+
is_sortable: false
|
30
|
+
}
|
31
|
+
)
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'add polymorphic smart field with default values' do
|
35
|
+
field = collection.fields.select { |field| field[:field] == :addressable_id }.first
|
36
|
+
|
37
|
+
expect(field).not_to be_nil
|
38
|
+
expect(field[:is_filterable]).to eq(true)
|
39
|
+
expect(field[:is_sortable]).to eq(true)
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'add polymorphic smart field with is_filterable option set to false' do
|
43
|
+
field = collection.fields.select { |field| field[:field] == :addressable_type }.first
|
44
|
+
|
45
|
+
expect(field).not_to be_nil
|
46
|
+
expect(field[:is_filterable]).to eq(false)
|
47
|
+
expect(field[:is_sortable]).to eq(true)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: forest_liana
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 9.
|
4
|
+
version: 9.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sandro Munda
|
@@ -395,6 +395,7 @@ files:
|
|
395
395
|
- spec/dummy/db/migrate/20220727114930_add_columns_to_products.rb
|
396
396
|
- spec/dummy/db/migrate/20231117084236_create_addresses.rb
|
397
397
|
- spec/dummy/db/schema.rb
|
398
|
+
- spec/dummy/lib/forest_liana/collections/address.rb
|
398
399
|
- spec/dummy/lib/forest_liana/collections/island.rb
|
399
400
|
- spec/dummy/lib/forest_liana/collections/location.rb
|
400
401
|
- spec/dummy/lib/forest_liana/collections/user.rb
|
@@ -403,6 +404,7 @@ files:
|
|
403
404
|
- spec/helpers/forest_liana/query_helper_spec.rb
|
404
405
|
- spec/helpers/forest_liana/schema_helper_spec.rb
|
405
406
|
- spec/lib/forest_liana/bootstrapper_spec.rb
|
407
|
+
- spec/lib/forest_liana/collection_spec.rb
|
406
408
|
- spec/lib/forest_liana/schema_file_updater_spec.rb
|
407
409
|
- spec/rails_helper.rb
|
408
410
|
- spec/requests/actions_controller_spec.rb
|
@@ -696,6 +698,7 @@ test_files:
|
|
696
698
|
- spec/dummy/db/migrate/20220727114930_add_columns_to_products.rb
|
697
699
|
- spec/dummy/db/migrate/20231117084236_create_addresses.rb
|
698
700
|
- spec/dummy/db/schema.rb
|
701
|
+
- spec/dummy/lib/forest_liana/collections/address.rb
|
699
702
|
- spec/dummy/lib/forest_liana/collections/island.rb
|
700
703
|
- spec/dummy/lib/forest_liana/collections/location.rb
|
701
704
|
- spec/dummy/lib/forest_liana/collections/user.rb
|
@@ -704,6 +707,7 @@ test_files:
|
|
704
707
|
- spec/helpers/forest_liana/query_helper_spec.rb
|
705
708
|
- spec/helpers/forest_liana/schema_helper_spec.rb
|
706
709
|
- spec/lib/forest_liana/bootstrapper_spec.rb
|
710
|
+
- spec/lib/forest_liana/collection_spec.rb
|
707
711
|
- spec/lib/forest_liana/schema_file_updater_spec.rb
|
708
712
|
- spec/rails_helper.rb
|
709
713
|
- spec/requests/actions_controller_spec.rb
|