forest_liana 9.15.6 → 9.15.7
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: d693ce27b46138de7814e1d7486d4d67b8e094ea57ecdaec552ab557ca870438
|
4
|
+
data.tar.gz: d236006d4441662e39102eb6791e8713754097b0ec1620f799557a6513c79531
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 71f50a75e497a526837a9418f05ee8b8c361d1685875df78b29c88883d69da7766814f6e3f0b372a2edfdade2f2341c8115f8da2368dc968c9e3e00e3cd4bbdc
|
7
|
+
data.tar.gz: 301ebd315a041666583fcd2386c578850aaf627e8c4f6a9cfe1e5ca194abec82f9eb98777a08d1afc343e5fe54d30f68097c51c4fa88dadf4701c0618535b835
|
@@ -60,28 +60,20 @@ module ForestLiana
|
|
60
60
|
unformatted_attr_name = serializer.unformat_name(attribute_name).to_sym
|
61
61
|
object = nil
|
62
62
|
is_collection = false
|
63
|
-
is_valid_attr = false
|
64
63
|
if serializer.has_one_relationships.has_key?(unformatted_attr_name)
|
65
64
|
# only added this condition
|
66
65
|
if root_object.class.reflect_on_association(unformatted_attr_name)&.polymorphic?
|
67
66
|
options[:context][:unoptimized] = true
|
68
67
|
end
|
69
68
|
|
70
|
-
is_valid_attr = true
|
71
69
|
attr_data = serializer.has_one_relationships[unformatted_attr_name]
|
72
70
|
object = serializer.has_one_relationship(unformatted_attr_name, attr_data)
|
73
71
|
elsif serializer.has_many_relationships.has_key?(unformatted_attr_name)
|
74
|
-
is_valid_attr = true
|
75
72
|
is_collection = true
|
76
73
|
attr_data = serializer.has_many_relationships[unformatted_attr_name]
|
77
74
|
object = serializer.has_many_relationship(unformatted_attr_name, attr_data)
|
78
75
|
end
|
79
76
|
|
80
|
-
if !is_valid_attr
|
81
|
-
raise ForestAdmin::JSONAPI::Serializer::InvalidIncludeError.new(
|
82
|
-
"'#{attribute_name}' is not a valid include.")
|
83
|
-
end
|
84
|
-
|
85
77
|
if attribute_name != serializer.format_name(attribute_name)
|
86
78
|
expected_name = serializer.format_name(attribute_name)
|
87
79
|
|
data/lib/forest_liana/version.rb
CHANGED
@@ -167,6 +167,52 @@ describe 'Requesting Tree resources', :type => :request do
|
|
167
167
|
end
|
168
168
|
end
|
169
169
|
end
|
170
|
+
|
171
|
+
describe 'csv' do
|
172
|
+
it 'should return CSV with correct headers and data' do
|
173
|
+
params = {
|
174
|
+
fields: { 'Tree' => 'id,name,owner', 'owner' => 'name'},
|
175
|
+
page: { 'number' => '1', 'size' => '10' },
|
176
|
+
searchExtended: '0',
|
177
|
+
sort: '-id',
|
178
|
+
timezone: 'Europe/Paris',
|
179
|
+
header: 'id,name,owner',
|
180
|
+
}
|
181
|
+
get '/forest/Tree.csv', params: params, headers: headers
|
182
|
+
|
183
|
+
expect(response.status).to eq(200)
|
184
|
+
expect(response.headers['Content-Type']).to include('text/csv')
|
185
|
+
expect(response.headers['Content-Disposition']).to include('attachment')
|
186
|
+
|
187
|
+
csv_content = response.body
|
188
|
+
csv_lines = csv_content.split("\n")
|
189
|
+
|
190
|
+
expect(csv_lines.first).to eq(params[:header])
|
191
|
+
expect(csv_lines[1]).to eq('1,Lemon Tree,Michel')
|
192
|
+
end
|
193
|
+
|
194
|
+
it 'returns CSV with only requested fields and ignores optional relation' do
|
195
|
+
params = {
|
196
|
+
fields: { 'Tree' => 'id,name', 'owner' => 'name'},
|
197
|
+
page: { 'number' => '1', 'size' => '10' },
|
198
|
+
searchExtended: '0',
|
199
|
+
sort: '-id',
|
200
|
+
timezone: 'Europe/Paris',
|
201
|
+
header: 'id,name',
|
202
|
+
}
|
203
|
+
get '/forest/Tree.csv', params: params, headers: headers
|
204
|
+
|
205
|
+
expect(response.status).to eq(200)
|
206
|
+
expect(response.headers['Content-Type']).to include('text/csv')
|
207
|
+
expect(response.headers['Content-Disposition']).to include('attachment')
|
208
|
+
|
209
|
+
csv_content = response.body
|
210
|
+
csv_lines = csv_content.split("\n")
|
211
|
+
|
212
|
+
expect(csv_lines.first).to eq(params[:header])
|
213
|
+
expect(csv_lines[1]).to eq('1,Lemon Tree')
|
214
|
+
end
|
215
|
+
end
|
170
216
|
end
|
171
217
|
|
172
218
|
describe 'Requesting User resources', :type => :request 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.15.
|
4
|
+
version: 9.15.7
|
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-08-
|
11
|
+
date: 2025-08-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|