Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(700) Add rollup data to host content endpoint #1300

Merged
Merged
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
36 changes: 30 additions & 6 deletions lib/gds_api/test_helpers/publishing_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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
Expand Down
9 changes: 9 additions & 0 deletions test/pacts/publishing_api/get_embedded_content_pact_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down