File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -92,7 +92,7 @@ def find
9292 include_directives : include_directives )
9393 end
9494
95- if ( JSONAPI . configuration . top_level_meta_include_page_count && page_options [ :record_count ] )
95+ if ( JSONAPI . configuration . top_level_meta_include_page_count && paginator && page_options [ :record_count ] )
9696 page_options [ :page_count ] = paginator . calculate_page_count ( page_options [ :record_count ] )
9797 end
9898
Original file line number Diff line number Diff line change @@ -2881,6 +2881,18 @@ def test_books_page_count_in_meta
28812881 assert_equal 'Book 0' , json_response [ 'data' ] [ 0 ] [ 'attributes' ] [ 'title' ]
28822882 end
28832883
2884+ def test_books_no_page_count_in_meta_with_none_paginator
2885+ Api ::V2 ::BookResource . paginator :none
2886+ JSONAPI . configuration . top_level_meta_include_page_count = true
2887+ assert_cacheable_get :index , params : { include : 'book-comments' }
2888+ JSONAPI . configuration . top_level_meta_include_page_count = false
2889+
2890+ assert_response :success
2891+ assert_nil json_response [ 'meta' ] [ 'page-count' ]
2892+ assert_equal 901 , json_response [ 'data' ] . size
2893+ assert_equal 'Book 0' , json_response [ 'data' ] [ 0 ] [ 'attributes' ] [ 'title' ]
2894+ end
2895+
28842896 def test_books_record_count_in_meta_custom_name
28852897 Api ::V2 ::BookResource . paginator :offset
28862898 JSONAPI . configuration . top_level_meta_include_record_count = true
You can’t perform that action at this time.
0 commit comments