Module: GdsApi::TestHelpers::Router

Defined in:
lib/gds_api/test_helpers/router.rb

Constant Summary collapse

ROUTER_API_ENDPOINT =
Plek.current.find('router-api')

Instance Method Summary collapse

Instance Method Details

#stub_redirect_registration(path, type, destination, redirect_type) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/gds_api/test_helpers/router.rb', line 20

def stub_redirect_registration(path, type, destination, redirect_type)
  redirect = { route: {
                incoming_path: path,
                route_type: type,
                handler: 'redirect',
                redirect_to: destination,
                redirect_type: redirect_type }
            }

  stub_router_put(redirect)
  stub_http_request(:post, "#{ROUTER_API_ENDPOINT}/routes/commit")
end

#stub_route_registration(path, type, backend_id) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/gds_api/test_helpers/router.rb', line 8

def stub_route_registration(path, type, backend_id)
  route = { route: {
              incoming_path: path,
              route_type: type,
              handler: 'backend',
              backend_id: backend_id }
          }

  stub_router_put(route)
  stub_http_request(:post, "#{ROUTER_API_ENDPOINT}/routes/commit")
end