Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/jsonapi/processor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
11 changes: 11 additions & 0 deletions test/integration/requests/request_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down