File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change 32
32
require 'jsonapi/serializable'
33
33
end
34
34
35
+ # Temporary fix until fixed upstream
36
+ # https://github.com/jsonapi-rb/jsonapi-serializable/pull/102
37
+ JSONAPI ::Serializable ::Resource . class_eval do
38
+ def requested_relationships ( fields )
39
+ @_relationships
40
+ end
41
+ end
42
+
35
43
require "jsonapi_compliable/extensions/extra_attribute"
36
44
require "jsonapi_compliable/extensions/boolean_attribute"
37
45
require "jsonapi_compliable/extensions/temp_id"
Original file line number Diff line number Diff line change @@ -193,6 +193,16 @@ def json
193
193
expect ( json_included_types ) . to match_array ( %w( books genres ) )
194
194
end
195
195
196
+ context 'when passing sparse fieldsets on primary data' do
197
+ context 'and sideloading' do
198
+ it 'is able to sideload without adding the field' do
199
+ get :index , params : { fields : { authors : 'first_name' } , include : 'books' }
200
+ expect ( json [ 'data' ] [ 0 ] [ 'relationships' ] ) . to be_present
201
+ expect ( json_included_types ) . to match_array ( %w( books ) )
202
+ end
203
+ end
204
+ end
205
+
196
206
context 'sideloading has_many' do
197
207
# TODO: may want to blow up here, only for index action
198
208
it 'allows pagination of sideloaded resource' do
You can’t perform that action at this time.
0 commit comments