diff --git a/CHANGELOG.md b/CHANGELOG.md index a791ad8b..534453b0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## Unreleased + +* Add rollup data to host content endpoint [PR](https://github.com/alphagov/gds-api-adapters/pull/1300) + ## 97.4.0 * Update dependencies diff --git a/lib/gds_api/test_helpers/publishing_api.rb b/lib/gds_api/test_helpers/publishing_api.rb index 1bf9e7f9..b127dc24 100644 --- a/lib/gds_api/test_helpers/publishing_api.rb +++ b/lib/gds_api/test_helpers/publishing_api.rb @@ -371,13 +371,28 @@ def stub_publishing_api_has_content(items, params = {}) # "base_path" => "/organisation/bar", # }, # }] # an array of content items that embed the target content_id + # rollup: { + # "views" => 1 + # "locations" => 1 + # "instances" => 1 + # "organisations" => 1 + # } # metadata with the total counts across all pages # ) - # @param content_id [UUID, Mocha::ParameterMatchers::Anything] + # @param content_id [UUID] # @param total Integer # @param total_pages Integer - # @param results [Hash] - def stub_publishing_api_has_embedded_content(content_id:, total: 0, total_pages: 0, results: [], page_number: nil, order: nil) - url = "#{PUBLISHING_API_V2_ENDPOINT}/content/#{content_id}/embedded" + # @param results [Array] + # @param rollup [Hash] + def stub_publishing_api_has_embedded_content( + content_id:, + total: 0, + total_pages: 0, + results: [], + page_number: nil, + order: nil, + rollup: {} + ) + url = "#{PUBLISHING_API_V2_ENDPOINT}/content/#{content_id}/host-content" query = { "page" => page_number, @@ -390,12 +405,20 @@ def stub_publishing_api_has_embedded_content(content_id:, total: 0, total_pages: "content_id" => content_id, "total" => total, "total_pages" => total_pages, + "rollup" => rollup, "results" => results, }.to_json) end - def stub_publishing_api_has_embedded_content_for_any_content_id(total: 0, total_pages: 0, results: [], page_number: nil, order: nil) - url = %r{\A#{PUBLISHING_API_V2_ENDPOINT}/content/[0-9a-fA-F-]{36}/embedded} + def stub_publishing_api_has_embedded_content_for_any_content_id( + total: 0, + total_pages: 0, + results: [], + page_number: nil, + order: nil, + rollup: {} + ) + url = %r{\A#{PUBLISHING_API_V2_ENDPOINT}/content/[0-9a-fA-F-]{36}/host-content} query = { "page" => page_number, @@ -408,6 +431,7 @@ def stub_publishing_api_has_embedded_content_for_any_content_id(total: 0, total_ "content_id" => SecureRandom.uuid, "total" => total, "total_pages" => total_pages, + "rollup" => rollup, "results" => results, }.to_json) end diff --git a/test/pacts/publishing_api/get_embedded_content_pact_test.rb b/test/pacts/publishing_api/get_embedded_content_pact_test.rb index a432acf0..72b1132d 100644 --- a/test/pacts/publishing_api/get_embedded_content_pact_test.rb +++ b/test/pacts/publishing_api/get_embedded_content_pact_test.rb @@ -22,11 +22,20 @@ }, } end + let(:rollup) do + { + "views" => 0, + "locations" => 1, + "instances" => 1, + "organisations" => 1, + } + end let(:expected_body) do { "content_id" => reusable_content_id, "total" => 1, "results" => [result], + "rollup" => rollup, } end