Skip to content

Commit 489cdbd

Browse files
committed
test(controller): add test for page_count in meta
1 parent d2e8124 commit 489cdbd

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

test/controllers/controller_test.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2687,6 +2687,21 @@ def test_books_record_count_in_meta
26872687
assert_equal 'Book 0', json_response['data'][0]['attributes']['title']
26882688
end
26892689

2690+
def test_books_page_count_in_meta
2691+
Api::V2::BookResource.paginator :paged
2692+
JSONAPI.configuration.top_level_meta_include_record_count = true
2693+
JSONAPI.configuration.top_level_meta_include_page_count = true
2694+
get :index, params: {include: 'book-comments'}
2695+
JSONAPI.configuration.top_level_meta_include_record_count = false
2696+
JSONAPI.configuration.top_level_meta_include_page_count = false
2697+
2698+
assert_response :success
2699+
assert_equal 901, json_response['meta']['record-count']
2700+
assert_equal 91, json_response['meta']['page-count']
2701+
assert_equal 10, json_response['data'].size
2702+
assert_equal 'Book 0', json_response['data'][0]['attributes']['title']
2703+
end
2704+
26902705
def test_books_record_count_in_meta_custom_name
26912706
Api::V2::BookResource.paginator :offset
26922707
JSONAPI.configuration.top_level_meta_include_record_count = true

0 commit comments

Comments
 (0)