File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -50,7 +50,7 @@ def top_level_meta
5050 @operation_results . results . each do |result |
5151 meta . merge! ( result . meta )
5252
53- if JSONAPI . configuration . top_level_meta_include_record_count
53+ if JSONAPI . configuration . top_level_meta_include_record_count && result . respond_to? ( :record_count )
5454 meta [ JSONAPI . configuration . top_level_meta_record_count_key ] = result . record_count
5555 end
5656 end
@@ -123,4 +123,4 @@ def results_to_hash
123123 end
124124 end
125125 end
126- end
126+ end
Original file line number Diff line number Diff line change @@ -227,6 +227,16 @@ def test_show_single
227227 assert_nil json_response [ 'included' ]
228228 end
229229
230+ def test_show_does_not_include_records_count_in_meta
231+ JSONAPI . configuration . top_level_meta_include_record_count = true
232+ get :show , { id : Post . first . id }
233+ assert_response :success
234+ assert_equal json_response [ 'meta' ] , nil
235+ ensure
236+ JSONAPI . configuration . top_level_meta_include_record_count = false
237+ end
238+
239+
230240 def test_show_single_with_includes
231241 get :show , { id : '1' , include : 'comments' }
232242 assert_response :success
@@ -2397,4 +2407,4 @@ def test_save_model_callbacks_fail
23972407 assert_response :unprocessable_entity
23982408 assert_match /Save failed or was cancelled/ , json_response [ 'errors' ] [ 0 ] [ 'detail' ]
23992409 end
2400- end
2410+ end
You can’t perform that action at this time.
0 commit comments