@@ -367,6 +367,15 @@ def test_show_does_not_include_records_count_in_meta
367367 JSONAPI . configuration . top_level_meta_include_record_count = false
368368 end
369369
370+ def test_show_does_not_include_pages_count_in_meta
371+ JSONAPI . configuration . top_level_meta_include_page_count = true
372+ get :show , { id : Post . first . id }
373+ assert_response :success
374+ assert_equal json_response [ 'meta' ] , nil
375+ ensure
376+ JSONAPI . configuration . top_level_meta_include_page_count = false
377+ end
378+
370379 def test_show_single_with_includes
371380 get :show , params : { id : '1' , include : 'comments' }
372381 assert_response :success
@@ -2678,6 +2687,18 @@ def test_books_record_count_in_meta
26782687 assert_equal 'Book 0' , json_response [ 'data' ] [ 0 ] [ 'attributes' ] [ 'title' ]
26792688 end
26802689
2690+ def test_books_page_count_in_meta
2691+ Api ::V2 ::BookResource . paginator :paged
2692+ JSONAPI . configuration . top_level_meta_include_page_count = true
2693+ get :index , params : { include : 'book-comments' }
2694+ JSONAPI . configuration . top_level_meta_include_page_count = false
2695+
2696+ assert_response :success
2697+ assert_equal 91 , json_response [ 'meta' ] [ 'page-count' ]
2698+ assert_equal 10 , json_response [ 'data' ] . size
2699+ assert_equal 'Book 0' , json_response [ 'data' ] [ 0 ] [ 'attributes' ] [ 'title' ]
2700+ end
2701+
26812702 def test_books_record_count_in_meta_custom_name
26822703 Api ::V2 ::BookResource . paginator :offset
26832704 JSONAPI . configuration . top_level_meta_include_record_count = true
@@ -2693,6 +2714,21 @@ def test_books_record_count_in_meta_custom_name
26932714 assert_equal 'Book 0' , json_response [ 'data' ] [ 0 ] [ 'attributes' ] [ 'title' ]
26942715 end
26952716
2717+ def test_books_page_count_in_meta_custom_name
2718+ Api ::V2 ::BookResource . paginator :paged
2719+ JSONAPI . configuration . top_level_meta_include_page_count = true
2720+ JSONAPI . configuration . top_level_meta_page_count_key = 'total_pages'
2721+
2722+ get :index , params : { include : 'book-comments' }
2723+ JSONAPI . configuration . top_level_meta_include_page_count = false
2724+ JSONAPI . configuration . top_level_meta_page_count_key = :page_count
2725+
2726+ assert_response :success
2727+ assert_equal 91 , json_response [ 'meta' ] [ 'total-pages' ]
2728+ assert_equal 10 , json_response [ 'data' ] . size
2729+ assert_equal 'Book 0' , json_response [ 'data' ] [ 0 ] [ 'attributes' ] [ 'title' ]
2730+ end
2731+
26962732 def test_books_offset_pagination_no_params_includes_query_count_one_level
26972733 Api ::V2 ::BookResource . paginator :offset
26982734
0 commit comments