Module: GdsApi::TestHelpers::LocalLinksManager
- Defined in:
- lib/gds_api/test_helpers/local_links_manager.rb
Constant Summary collapse
- LOCAL_LINKS_MANAGER_ENDPOINT =
Plek.current.find("local-links-manager")
Instance Method Summary collapse
- #stub_local_links_manager_does_not_have_an_authority(authority_slug) ⇒ Object
- #stub_local_links_manager_does_not_have_required_objects(authority_slug, lgsl, lgil) ⇒ Object
- #stub_local_links_manager_has_a_district_and_county_local_authority(district_slug, county_slug) ⇒ Object
- #stub_local_links_manager_has_a_link(authority_slug:, lgsl:, lgil:, url:, country_name: "England", status: "ok") ⇒ Object
- #stub_local_links_manager_has_a_local_authority(authority_slug) ⇒ Object
- #stub_local_links_manager_has_a_local_authority_without_homepage(authority_slug) ⇒ Object
- #stub_local_links_manager_has_no_link(authority_slug:, lgsl:, lgil:, country_name: "England") ⇒ Object
- #stub_local_links_manager_has_no_link_and_no_homepage_url(authority_slug:, lgsl:, lgil:, country_name: "England") ⇒ Object
- #stub_local_links_manager_request_with_missing_parameters(authority_slug, lgsl, lgil) ⇒ Object
- #stub_local_links_manager_request_without_local_authority_slug ⇒ Object
Instance Method Details
#stub_local_links_manager_does_not_have_an_authority(authority_slug) ⇒ Object
129 130 131 132 133 |
# File 'lib/gds_api/test_helpers/local_links_manager.rb', line 129 def () stub_request(:get, "#{LOCAL_LINKS_MANAGER_ENDPOINT}/api/local-authority") .with(query: { authority_slug: }) .to_return(body: {}.to_json, status: 404) end |
#stub_local_links_manager_does_not_have_required_objects(authority_slug, lgsl, lgil) ⇒ Object
75 76 77 78 79 80 81 |
# File 'lib/gds_api/test_helpers/local_links_manager.rb', line 75 def stub_local_links_manager_does_not_have_required_objects(, lgsl, lgil) params = { authority_slug: , lgsl: lgsl, lgil: lgil } stub_request(:get, "#{LOCAL_LINKS_MANAGER_ENDPOINT}/api/link") .with(query: params) .to_return(body: {}.to_json, status: 404) end |
#stub_local_links_manager_has_a_district_and_county_local_authority(district_slug, county_slug) ⇒ Object
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/gds_api/test_helpers/local_links_manager.rb', line 100 def (district_slug, county_slug) response = { "local_authorities" => [ { "name" => district_slug.capitalize, "homepage_url" => "http://#{district_slug}.example.com", "country_name" => "England", "tier" => "district", }, { "name" => county_slug.capitalize, "homepage_url" => "http://#{county_slug}.example.com", "country_name" => "England", "tier" => "county", }, ], } stub_request(:get, "#{LOCAL_LINKS_MANAGER_ENDPOINT}/api/local-authority") .with(query: { authority_slug: district_slug }) .to_return(body: response.to_json, status: 200) end |
#stub_local_links_manager_has_a_link(authority_slug:, lgsl:, lgil:, url:, country_name: "England", status: "ok") ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/gds_api/test_helpers/local_links_manager.rb', line 8 def stub_local_links_manager_has_a_link(authority_slug:, lgsl:, lgil:, url:, country_name: "England", status: "ok") response = { "local_authority" => { "name" => .capitalize, "snac" => "00AG", "tier" => "unitary", "homepage_url" => "http://#{}.example.com", "country_name" => country_name, }, "local_interaction" => { "lgsl_code" => lgsl, "lgil_code" => lgil, "url" => url, "status" => status, }, } stub_request(:get, "#{LOCAL_LINKS_MANAGER_ENDPOINT}/api/link") .with(query: { authority_slug: , lgsl: lgsl, lgil: lgil }) .to_return(body: response.to_json, status: 200) end |
#stub_local_links_manager_has_a_local_authority(authority_slug) ⇒ Object
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/gds_api/test_helpers/local_links_manager.rb', line 83 def () response = { "local_authorities" => [ { "name" => .capitalize, "homepage_url" => "http://#{}.example.com", "country_name" => "England", "tier" => "unitary", }, ], } stub_request(:get, "#{LOCAL_LINKS_MANAGER_ENDPOINT}/api/local-authority") .with(query: { authority_slug: }) .to_return(body: response.to_json, status: 200) end |
#stub_local_links_manager_has_a_local_authority_without_homepage(authority_slug) ⇒ Object
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 |
# File 'lib/gds_api/test_helpers/local_links_manager.rb', line 135 def () response = { "local_authorities" => [ { "name" => .capitalize, "homepage_url" => "", "country_name" => "England", "tier" => "unitary", }, ], } stub_request(:get, "#{LOCAL_LINKS_MANAGER_ENDPOINT}/api/local-authority") .with(query: { authority_slug: }) .to_return(body: response.to_json, status: 200) end |
#stub_local_links_manager_has_no_link(authority_slug:, lgsl:, lgil:, country_name: "England") ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/gds_api/test_helpers/local_links_manager.rb', line 30 def stub_local_links_manager_has_no_link(authority_slug:, lgsl:, lgil:, country_name: "England") response = { "local_authority" => { "name" => .capitalize, "snac" => "00AG", "tier" => "unitary", "homepage_url" => "http://#{}.example.com", "country_name" => country_name, }, } stub_request(:get, "#{LOCAL_LINKS_MANAGER_ENDPOINT}/api/link") .with(query: { authority_slug: , lgsl: lgsl, lgil: lgil }) .to_return(body: response.to_json, status: 200) end |
#stub_local_links_manager_has_no_link_and_no_homepage_url(authority_slug:, lgsl:, lgil:, country_name: "England") ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/gds_api/test_helpers/local_links_manager.rb', line 46 def stub_local_links_manager_has_no_link_and_no_homepage_url(authority_slug:, lgsl:, lgil:, country_name: "England") response = { "local_authority" => { "name" => .capitalize, "snac" => "00AG", "tier" => "unitary", "homepage_url" => nil, "country_name" => country_name, }, } stub_request(:get, "#{LOCAL_LINKS_MANAGER_ENDPOINT}/api/link") .with(query: { authority_slug: , lgsl: lgsl, lgil: lgil }) .to_return(body: response.to_json, status: 200) end |
#stub_local_links_manager_request_with_missing_parameters(authority_slug, lgsl, lgil) ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/gds_api/test_helpers/local_links_manager.rb', line 62 def stub_local_links_manager_request_with_missing_parameters(, lgsl, lgil) # convert nil to an empty string, otherwise query param is not expressed correctly params = { authority_slug: || "", lgsl: lgsl || "", lgil: lgil || "", } stub_request(:get, "#{LOCAL_LINKS_MANAGER_ENDPOINT}/api/link") .with(query: params) .to_return(body: {}.to_json, status: 400) end |
#stub_local_links_manager_request_without_local_authority_slug ⇒ Object
123 124 125 126 127 |
# File 'lib/gds_api/test_helpers/local_links_manager.rb', line 123 def stub_request(:get, "#{LOCAL_LINKS_MANAGER_ENDPOINT}/api/local-authority") .with(query: { authority_slug: "" }) .to_return(body: {}.to_json, status: 400) end |