forest_liana 9.15.7 → 9.15.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 196dd946e590abc0f8d08471986655e8bd3244638cb278e91fd9e13ae446dcf4
|
4
|
+
data.tar.gz: 6fc5262c9b202656e03f6f490d0c25776cee50c5af1743705667f06aee69d205
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 72a7ce8cca5d0e3d0e3829a5db69120d30c1c99e6ce09a766a00bb9816b52e071c4ed2c8a57879d0ce2e09213bc24b32ee782cd382ec4328af2131baa5b30167
|
7
|
+
data.tar.gz: d78f92c535f06d035ea1eb896621dfc8cb0c9f77001f252b84f594c8f5c58215b57a7bdb7cac5f339f7e7f7612baf506ef94e6a983bcec8f7cd849cedde6072b
|
@@ -188,7 +188,11 @@ module ForestLiana
|
|
188
188
|
else
|
189
189
|
smart_relations.each do |smart_relation|
|
190
190
|
if smart_relation[:field].to_s == relation_name
|
191
|
-
|
191
|
+
if smart_relation[:reference].split('.').first == params[:collection]
|
192
|
+
fields[relation_name] = relation_fields
|
193
|
+
else
|
194
|
+
fields[smart_relation[:reference].split('.').first] = relation_fields
|
195
|
+
end
|
192
196
|
end
|
193
197
|
end
|
194
198
|
end
|
data/lib/forest_liana/version.rb
CHANGED
@@ -606,4 +606,93 @@ describe 'Requesting Actions routes', :type => :request do
|
|
606
606
|
controller.send(:serialize_models, records, options)
|
607
607
|
end
|
608
608
|
end
|
609
|
+
|
610
|
+
describe 'fields_per_model method' do
|
611
|
+
let(:model) { Island }
|
612
|
+
let(:collection_name) { 'Island' }
|
613
|
+
|
614
|
+
before do
|
615
|
+
forest_collection = double('forest_collection')
|
616
|
+
allow(ForestLiana).to receive(:apimap).and_return([forest_collection])
|
617
|
+
allow(forest_collection).to receive(:name).and_return(collection_name)
|
618
|
+
end
|
619
|
+
|
620
|
+
context 'with smart relations pointing to external models' do
|
621
|
+
it 'should use reference model name as key for external smart relations' do
|
622
|
+
smart_relations = [
|
623
|
+
{
|
624
|
+
field: :organization,
|
625
|
+
reference: 'Api__OrganizationsView.id',
|
626
|
+
is_virtual: true,
|
627
|
+
is_searchable: false,
|
628
|
+
type: 'String'
|
629
|
+
}
|
630
|
+
]
|
631
|
+
|
632
|
+
forest_collection = double('forest_collection')
|
633
|
+
allow(forest_collection).to receive(:name).and_return(collection_name)
|
634
|
+
allow(forest_collection).to receive(:fields_smart_belongs_to).and_return(smart_relations)
|
635
|
+
allow(ForestLiana).to receive(:apimap).and_return([forest_collection])
|
636
|
+
|
637
|
+
params_fields = ActionController::Parameters.new({
|
638
|
+
'organization' => 'name'
|
639
|
+
})
|
640
|
+
|
641
|
+
mock_params = ActionController::Parameters.new({
|
642
|
+
collection: 'Island',
|
643
|
+
fields: { 'Island' => 'id,name', 'organization' => 'name'},
|
644
|
+
page: { 'number' => '1', 'size' => '10' },
|
645
|
+
searchExtended: '0',
|
646
|
+
sort: '-id',
|
647
|
+
timezone: 'Europe/Paris'
|
648
|
+
})
|
649
|
+
allow(controller).to receive(:params).and_return(mock_params)
|
650
|
+
|
651
|
+
result = controller.send(:fields_per_model, params_fields, model)
|
652
|
+
|
653
|
+
expect(result).to have_key('Api__OrganizationsView')
|
654
|
+
expect(result['Api__OrganizationsView']).to eq('name')
|
655
|
+
expect(result).not_to have_key('organization')
|
656
|
+
end
|
657
|
+
end
|
658
|
+
|
659
|
+
context 'with smart relations pointing to same collection (self-reference)' do
|
660
|
+
it 'should use relation name as key for self-referencing smart relations' do
|
661
|
+
smart_relations = [
|
662
|
+
{
|
663
|
+
field: :parent_island,
|
664
|
+
reference: 'Island.id',
|
665
|
+
is_virtual: true,
|
666
|
+
is_searchable: false,
|
667
|
+
type: 'String'
|
668
|
+
}
|
669
|
+
]
|
670
|
+
|
671
|
+
forest_collection = double('forest_collection')
|
672
|
+
allow(forest_collection).to receive(:name).and_return(collection_name)
|
673
|
+
allow(forest_collection).to receive(:fields_smart_belongs_to).and_return(smart_relations)
|
674
|
+
allow(ForestLiana).to receive(:apimap).and_return([forest_collection])
|
675
|
+
|
676
|
+
params_fields = ActionController::Parameters.new({
|
677
|
+
'parent_island' => 'name'
|
678
|
+
})
|
679
|
+
|
680
|
+
mock_params = ActionController::Parameters.new({
|
681
|
+
collection: 'Island',
|
682
|
+
fields: { 'Island' => 'id,name', 'parent_island' => 'name'},
|
683
|
+
page: { 'number' => '1', 'size' => '10' },
|
684
|
+
searchExtended: '0',
|
685
|
+
sort: '-id',
|
686
|
+
timezone: 'Europe/Paris'
|
687
|
+
})
|
688
|
+
allow(controller).to receive(:params).and_return(mock_params)
|
689
|
+
|
690
|
+
result = controller.send(:fields_per_model, params_fields, model)
|
691
|
+
|
692
|
+
expect(result).to have_key('parent_island')
|
693
|
+
expect(result['parent_island']).to eq('name')
|
694
|
+
expect(result).not_to have_key('Island')
|
695
|
+
end
|
696
|
+
end
|
697
|
+
end
|
609
698
|
end
|
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.15.
|
4
|
+
version: 9.15.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sandro Munda
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-
|
11
|
+
date: 2025-09-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|