Module: GdsApi::TestHelpers::CollectionsApi

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

Constant Summary collapse

COLLECTIONS_API_ENDPOINT =
Plek.current.find('collections-api')

Instance Method Summary collapse

Instance Method Details

#collections_api_example_documentsObject



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/gds_api/test_helpers/collections_api.rb', line 31

def collections_api_example_documents
  [
    {
      title: "Oil rig safety requirements",
      link: "http://example.com/documents/oil-rig-safety-requirements",
      public_updated_at: "2014-10-27T09:35:57+00:00",
      latest_change_note: "Updated topics"
    },
    {
      title: "Undersea piping restrictions",
      link: "http://example.com/documents/undersea-piping-restrictions",
      public_updated_at: "2014-10-15T09:36:18+01:00",
      latest_change_note: nil
    },
    {
      title: "North sea shipping lanes",
      link: "http://example.com/documents/north-sea-shipping-lanes",
      public_updated_at: nil,
      latest_change_note: "Corrected shipping lane"
    },
    {
      title: "Oil rig staffing",
      link: "http://example.com/documents/oil-rig-staffing",
      public_updated_at: "2014-09-22T09:37:00+01:00",
      latest_change_note: "Added annual leave allowances"
    },
  ]
end

#collections_api_has_content_for(base_path, options = {}) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/gds_api/test_helpers/collections_api.rb', line 9

def collections_api_has_content_for(base_path, options={})
  body_options = options.delete(:return_body_options) || {}

  params = options.any? ? "?#{Rack::Utils.build_nested_query(options)}" : ''
  url = COLLECTIONS_API_ENDPOINT + "/specialist-sectors" + base_path + params

  stub_request(:get, url).to_return(
    status: 200,
    body: body_with_options(
      body_options.merge(base_path: base_path)
    ).to_json,
  )
end

#collections_api_has_no_content_for(base_path) ⇒ Object



23
24
25
26
27
28
29
# File 'lib/gds_api/test_helpers/collections_api.rb', line 23

def collections_api_has_no_content_for(base_path)
  url = COLLECTIONS_API_ENDPOINT + "/specialist-sectors" + base_path

  stub_request(:get, url).to_return(
    status: 404
  )
end