Module: GdsApi::TestHelpers::Worldwide
- Includes:
- CommonResponses
- Defined in:
- lib/gds_api/test_helpers/worldwide.rb
Constant Summary collapse
- WORLDWIDE_API_ENDPOINT =
Plek.new.website_root
Instance Method Summary collapse
- #stub_content_store_has_worldwide_organisation(content_item) ⇒ Object
- #stub_search_api_has_organisations_for_location(location_slug, organisation_content_items) ⇒ Object
- #stub_worldwide_api_has_location(location_slug) ⇒ Object
- #stub_worldwide_api_has_locations(location_slugs) ⇒ Object
Methods included from CommonResponses
#acronymize_slug, #plural_response_base, #response_base, #titleize_slug
Instance Method Details
#stub_content_store_has_worldwide_organisation(content_item) ⇒ Object
72 73 74 75 76 77 |
# File 'lib/gds_api/test_helpers/worldwide.rb', line 72 def stub_content_store_has_worldwide_organisation(content_item) base_path = content_item["base_path"] stub_request(:get, "#{WORLDWIDE_API_ENDPOINT}/api/content#{base_path}") .to_return(status: 200, body: content_item.to_json) end |
#stub_search_api_has_organisations_for_location(location_slug, organisation_content_items) ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/gds_api/test_helpers/worldwide.rb', line 55 def stub_search_api_has_organisations_for_location(location_slug, organisation_content_items) response = { "results": organisation_content_items.map do |content_item| { "link": content_item["base_path"], } end, } stub_request(:get, "#{WORLDWIDE_API_ENDPOINT}/api/search.json?filter_format=worldwide_organisation&filter_world_locations=#{location_slug}") .to_return(status: 200, body: response.to_json) organisation_content_items.each do |content_item| stub_content_store_has_worldwide_organisation(content_item) end end |
#stub_worldwide_api_has_location(location_slug) ⇒ Object
51 52 53 |
# File 'lib/gds_api/test_helpers/worldwide.rb', line 51 def stub_worldwide_api_has_location(location_slug) stub_worldwide_api_has_locations([location_slug]) end |
#stub_worldwide_api_has_locations(location_slugs) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/gds_api/test_helpers/worldwide.rb', line 11 def stub_worldwide_api_has_locations(location_slugs) international_delegation_slugs = location_slugs.select do |slug| slug =~ /(delegation|mission)/ end international_delegations = international_delegation_slugs.map do |slug| { "active": true, "analytics_identifier": "WL1", "content_id": "content_id_for_#{slug}", "iso2": slug[0..1].upcase, "name": titleize_slug(slug, title_case: true), "slug": slug, "updated_at": "2013-03-25T13:06:42+00:00", } end world_locations = (location_slugs - international_delegation_slugs).map do |slug| { "active": true, "analytics_identifier": "WL1", "content_id": "content_id_for_#{slug}", "iso2": slug[0..1].upcase, "name": titleize_slug(slug, title_case: true), "slug": slug, "updated_at": "2013-03-25T13:06:42+00:00", } end content_item = { "details": { "international_delegation": international_delegations, "world_locations": world_locations, }, } stub_request(:get, "#{WORLDWIDE_API_ENDPOINT}/api/content/world") .to_return(status: 200, body: content_item.to_json) end |