module GdsApi::TestHelpers::ContentStore

def stub_content_store_has_item(base_path, body = content_item_for_base_path(base_path), options = {})

def stub_content_store_has_item(base_path, body = content_item_for_base_path(base_path), options = {})
  max_age = options.fetch(:max_age, 900)
  visibility = options[:private] ? "private" : "public"
  url = stub_content_store_endpoint(options[:draft]) + "/content" + base_path
  body = body.to_json unless body.is_a?(String)
  stub_request(:get, url).to_return(
    status: 200,
    body: body,
    headers: {
      cache_control: "#{visibility}, max-age=#{max_age}",
      date: Time.now.httpdate,
    },
  )
end