Module: GdsApi::TestHelpers::ContentItemHelpers

Included in:
ContentStore, PublishingApi, PublishingApiV2
Defined in:
lib/gds_api/test_helpers/content_item_helpers.rb

Instance Method Summary collapse

Instance Method Details

#content_item_for_base_path(base_path) ⇒ Object


5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/gds_api/test_helpers/content_item_helpers.rb', line 5

def content_item_for_base_path(base_path)
  {
    "title" => titleize_base_path(base_path),
    "description" => "Description for #{base_path}",
    "schema_name" => "guide",
    "document_type" => "guide",
    "need_ids" => ["100001"],
    "public_updated_at" => "2014-05-06T12:01:00+00:00",
    # base_path is added in as necessary (ie for content-store GET responses)
    # "base_path" => base_path,
    "details" => {
      "body" => "Some content for #{base_path}",
    }
  }
end

#gone_content_item_for_base_path(base_path) ⇒ Object


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

def gone_content_item_for_base_path(base_path)
  {
    "title" => nil,
    "description" => nil,
    "document_type" => "gone",
    "schema_name" => "gone",
    "public_updated_at" => nil,
    "base_path" => base_path,
    "withdrawn_notice" => {},
    "details" => {}
  }
end

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


34
35
36
37
38
39
40
# File 'lib/gds_api/test_helpers/content_item_helpers.rb', line 34

def titleize_base_path(base_path, options = {})
  if options[:title_case]
    base_path.tr("-", " ").gsub(/\b./, &:upcase)
  else
    base_path.gsub(%r{[-/]}, " ").strip.capitalize
  end
end