File tree Expand file tree Collapse file tree 2 files changed +32
-1
lines changed Expand file tree Collapse file tree 2 files changed +32
-1
lines changed Original file line number Diff line number Diff line change 7171
7272 expect ( hash ) . to eq expected
7373 end
74+
75+ it 'handles invalid input' do
76+ args = Object . new
77+ hash = JSONAPI ::IncludeDirective ::Parser . parse_include_args ( args )
78+ expected = { }
79+
80+ expect ( hash ) . to eq expected
81+ end
7482end
Original file line number Diff line number Diff line change @@ -84,7 +84,7 @@ def jsonapi_id
8484 end
8585
8686 def jsonapi_related ( included )
87- included . include? ( :author ) ? { author : @author } : { }
87+ included . include? ( :author ) ? { author : [ @author ] } : { }
8888 end
8989
9090 def as_jsonapi ( options = { } )
@@ -391,4 +391,27 @@ def as_jsonapi(options = {})
391391
392392 expect ( actual ) . to eq ( expected )
393393 end
394+
395+ class ErrorResource
396+ def initialize ( id , title )
397+ @id = id
398+ @title = title
399+ end
400+
401+ def as_jsonapi
402+ { id : @id , title : @title }
403+ end
404+ end
405+
406+ it 'renders errors' do
407+ errors = [ ErrorResource . new ( '1' , 'Not working' ) ,
408+ ErrorResource . new ( '2' , 'Works poorly' ) ]
409+ actual = JSONAPI . render ( errors : errors )
410+ expected = {
411+ errors : [ { id : '1' , title : 'Not working' } ,
412+ { id : '2' , title : 'Works poorly' } ]
413+ }
414+
415+ expect ( actual ) . to eq ( expected )
416+ end
394417end
You can’t perform that action at this time.
0 commit comments