Module: PublishingPlatformApi::TestHelpers::Router
- Defined in:
- lib/publishing_platform_api/test_helpers/router.rb
Constant Summary collapse
- ROUTER_API_ENDPOINT =
PublishingPlatformLocation.find("router-api")
Instance Method Summary collapse
- #stub_all_router_registration ⇒ Object
- #stub_gone_route_registration(path, type) ⇒ Object
- #stub_redirect_registration(path, type, destination, redirect_type, segments_mode = nil) ⇒ Object
- #stub_route_registration(path, type, backend_id) ⇒ Object
- #stub_router_doesnt_have_route(path, bearer_token = ENV["ROUTER_API_BEARER_TOKEN"]) ⇒ Object
- #stub_router_has_backend_route(path, backend_id:, route_type: "exact", disabled: false) ⇒ Object
- #stub_router_has_gone_route(path, route_type: "exact", disabled: false) ⇒ Object
- #stub_router_has_redirect_route(path, redirect_to:, redirect_type: "permanent", route_type: "exact", disabled: false) ⇒ Object
- #stub_router_has_route(path, route, bearer_token = ENV["ROUTER_API_BEARER_TOKEN"]) ⇒ Object
Instance Method Details
#stub_all_router_registration ⇒ Object
30 31 32 |
# File 'lib/publishing_platform_api/test_helpers/router.rb', line 30 def stub_all_router_registration stub_request(:put, "#{ROUTER_API_ENDPOINT}/routes") end |
#stub_gone_route_registration(path, type) ⇒ Object
58 59 60 61 62 63 64 65 66 |
# File 'lib/publishing_platform_api/test_helpers/router.rb', line 58 def stub_gone_route_registration(path, type) stub_route_put({ route: { incoming_path: path, route_type: type, handler: "gone", }, }) end |
#stub_redirect_registration(path, type, destination, redirect_type, segments_mode = nil) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/publishing_platform_api/test_helpers/router.rb', line 45 def stub_redirect_registration(path, type, destination, redirect_type, segments_mode = nil) stub_route_put({ route: { incoming_path: path, route_type: type, handler: "redirect", redirect_to: destination, redirect_type:, segments_mode:, }, }) end |
#stub_route_registration(path, type, backend_id) ⇒ Object
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/publishing_platform_api/test_helpers/router.rb', line 34 def stub_route_registration(path, type, backend_id) stub_route_put({ route: { incoming_path: path, route_type: type, handler: "backend", backend_id:, }, }) end |
#stub_router_doesnt_have_route(path, bearer_token = ENV["ROUTER_API_BEARER_TOKEN"]) ⇒ Object
14 15 16 |
# File 'lib/publishing_platform_api/test_helpers/router.rb', line 14 def stub_router_doesnt_have_route(path, bearer_token = ENV["ROUTER_API_BEARER_TOKEN"]) stub_get_route(path, bearer_token).to_return(status: 404) end |
#stub_router_has_backend_route(path, backend_id:, route_type: "exact", disabled: false) ⇒ Object
18 19 20 |
# File 'lib/publishing_platform_api/test_helpers/router.rb', line 18 def stub_router_has_backend_route(path, backend_id:, route_type: "exact", disabled: false) stub_router_has_route(path, handler: "backend", backend_id:, disabled:, route_type:) end |
#stub_router_has_gone_route(path, route_type: "exact", disabled: false) ⇒ Object
26 27 28 |
# File 'lib/publishing_platform_api/test_helpers/router.rb', line 26 def stub_router_has_gone_route(path, route_type: "exact", disabled: false) stub_router_has_route(path, handler: "gone", route_type:, disabled:) end |
#stub_router_has_redirect_route(path, redirect_to:, redirect_type: "permanent", route_type: "exact", disabled: false) ⇒ Object
22 23 24 |
# File 'lib/publishing_platform_api/test_helpers/router.rb', line 22 def stub_router_has_redirect_route(path, redirect_to:, redirect_type: "permanent", route_type: "exact", disabled: false) stub_router_has_route(path, handler: "redirect", redirect_to:, redirect_type:, disabled:, route_type:) end |
#stub_router_has_route(path, route, bearer_token = ENV["ROUTER_API_BEARER_TOKEN"]) ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/publishing_platform_api/test_helpers/router.rb', line 6 def stub_router_has_route(path, route, bearer_token = ENV["ROUTER_API_BEARER_TOKEN"]) stub_get_route(path, bearer_token).to_return( status: 200, body: route.to_json, headers: { "Content-Type" => "application/json" }, ) end |