diff --git a/lib/jsonapi/processor.rb b/lib/jsonapi/processor.rb index 88c45559..8ac63e85 100644 --- a/lib/jsonapi/processor.rb +++ b/lib/jsonapi/processor.rb @@ -204,7 +204,7 @@ def show_related_resources options) end - if (JSONAPI.configuration.top_level_meta_include_page_count && opts[:record_count]) + if (paginator && JSONAPI.configuration.top_level_meta_include_page_count && opts[:record_count]) opts[:page_count] = paginator.calculate_page_count(opts[:record_count]) end diff --git a/test/integration/requests/request_test.rb b/test/integration/requests/request_test.rb index 1863b5c7..5364cba4 100644 --- a/test/integration/requests/request_test.rb +++ b/test/integration/requests/request_test.rb @@ -813,6 +813,17 @@ def test_pagination_related_resources_links_meta JSONAPI.configuration.top_level_meta_include_record_count = false end + def test_pagination_none_related_resources_and_top_level_meta_include_page_count + Api::V2::BookResource.paginator :offset + Api::V2::BookCommentResource.paginator :none + JSONAPI.configuration.top_level_meta_include_page_count = true + assert_cacheable_jsonapi_get '/api/v2/books/1/book_comments' + assert json_response['data'] + assert_nil json_response.dig('meta', 'record_count') + ensure + JSONAPI.configuration.top_level_meta_include_page_count = false + end + def test_filter_related_resources_relationship_filter Api::V2::BookCommentResource.paginator :offset JSONAPI.configuration.top_level_meta_include_record_count = true