File tree 2 files changed +13
-1
lines changed
2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -69,7 +69,7 @@ def find
69
69
include_directives : include_directives )
70
70
end
71
71
72
- if ( JSONAPI . configuration . top_level_meta_include_page_count && page_options [ :record_count ] )
72
+ if ( JSONAPI . configuration . top_level_meta_include_page_count && paginator && page_options [ :record_count ] )
73
73
page_options [ :page_count ] = paginator ? paginator . calculate_page_count ( page_options [ :record_count ] ) : 1
74
74
end
75
75
Original file line number Diff line number Diff line change @@ -3033,6 +3033,18 @@ def test_books_page_count_in_meta
3033
3033
assert_equal 'Book 0' , json_response [ 'data' ] [ 0 ] [ 'attributes' ] [ 'title' ]
3034
3034
end
3035
3035
3036
+ def test_books_no_page_count_in_meta_with_none_paginator
3037
+ Api ::V2 ::BookResource . paginator :none
3038
+ JSONAPI . configuration . top_level_meta_include_page_count = true
3039
+ assert_cacheable_get :index , params : { include : 'book-comments' }
3040
+ JSONAPI . configuration . top_level_meta_include_page_count = false
3041
+
3042
+ assert_response :success
3043
+ assert_nil json_response [ 'meta' ] [ 'page-count' ]
3044
+ assert_equal 901 , json_response [ 'data' ] . size
3045
+ assert_equal 'Book 0' , json_response [ 'data' ] [ 0 ] [ 'attributes' ] [ 'title' ]
3046
+ end
3047
+
3036
3048
def test_books_record_count_in_meta_custom_name
3037
3049
Api ::V2 ::BookResource . paginator :offset
3038
3050
JSONAPI . configuration . top_level_meta_include_record_count = true
You can’t perform that action at this time.
0 commit comments