File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ 2.6.9
Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ def self.install!
3737 # @return [NilClass]
3838 def self . add_errors_renderer!
3939 ActionController ::Renderers . add ( :jsonapi_errors ) do |resource , options |
40- self . content_type || = Mime [ :jsonapi ]
40+ self . content_type = Mime [ :jsonapi ] if self . media_type . nil?
4141
4242 many = JSONAPI ::Rails . is_collection? ( resource , options [ :is_collection ] )
4343 resource = [ resource ] unless many
@@ -47,7 +47,7 @@ def self.add_errors_renderer!
4747 ) unless resource . is_a? ( ActiveModel ::Errors )
4848
4949 errors = [ ]
50- model = resource . instance_variable_get ( ' @base' )
50+ model = resource . instance_variable_get ( : @base)
5151
5252 if respond_to? ( :jsonapi_serializer_class , true )
5353 model_serializer = jsonapi_serializer_class ( model , false )
@@ -90,7 +90,7 @@ def self.add_errors_renderer!
9090 # @return [NilClass]
9191 def self . add_renderer!
9292 ActionController ::Renderers . add ( :jsonapi ) do |resource , options |
93- self . content_type || = Mime [ :jsonapi ]
93+ self . content_type = Mime [ :jsonapi ] if self . media_type . nil?
9494
9595 JSONAPI_METHODS_MAPPING . to_a [ 0 ..1 ] . each do |opt , method_name |
9696 next unless respond_to? ( method_name , true )
Original file line number Diff line number Diff line change 3131
3232 it do
3333 expect ( response ) . to have_http_status ( :unprocessable_entity )
34+ expect ( response . media_type ) . to eq ( 'application/vnd.api+json' )
3435 expect ( response_json [ 'errors' ] . size ) . to eq ( 1 )
3536 expect ( response_json [ 'errors' ] [ 0 ] [ 'status' ] ) . to eq ( '422' )
3637 expect ( response_json [ 'errors' ] [ 0 ] [ 'title' ] )
Original file line number Diff line number Diff line change 2525 it do
2626 expect ( response ) . to have_http_status ( :ok )
2727 expect ( response_json [ 'data' ] . size ) . to eq ( users . size )
28+ expect ( response . media_type ) . to eq ( 'application/vnd.api+json' )
2829
2930 response_json [ 'data' ] . each do |item |
3031 user = users . detect { |u | u . id == item [ 'id' ] . to_i }
You can’t perform that action at this time.
0 commit comments