Skip to content

Commit

Permalink
Update embedded content helper to add rollup data
Browse files Browse the repository at this point in the history
  • Loading branch information
pezholio committed Nov 28, 2024
1 parent 21a90bf commit e6c398e
Showing 1 changed file with 28 additions and 4 deletions.
32 changes: 28 additions & 4 deletions lib/gds_api/test_helpers/publishing_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -371,12 +371,27 @@ 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)
# @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}/embedded"

query = {
Expand All @@ -390,11 +405,19 @@ 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)
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}/embedded}

query = {
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

0 comments on commit e6c398e

Please sign in to comment.