Browse Source

Update existing postcode stubs to include in/outcode

CLDC-1468-add-postcode-to-sales-property-info-journey
Mo Seedat 2 years ago
parent
commit
f833705c21
  1. 8
      app/services/postcode_service.rb
  2. 2
      spec/features/form/page_routing_spec.rb
  3. 6
      spec/models/lettings_log_spec.rb
  4. 2
      spec/models/location_spec.rb
  5. 2
      spec/requests/lettings_logs_controller_spec.rb

8
app/services/postcode_service.rb

@ -21,10 +21,10 @@ class PostcodeService
if postcode_lookup && postcode_lookup.info.present? if postcode_lookup && postcode_lookup.info.present?
OpenStruct.new({ OpenStruct.new({
location_code: postcode_lookup.codes["admin_district"], location_code: postcode_lookup.codes["admin_district"],
location_admin_district: postcode_lookup&.admin_district, location_admin_district: postcode_lookup.admin_district,
incode: postcode_lookup&.incode, incode: postcode_lookup.incode,
outcode: postcode_lookup&.outcode, outcode: postcode_lookup.outcode,
result?: postcode_lookup&.outcode&.present?, result?: postcode_lookup.outcode.present?,
}) })
end end
end end

2
spec/features/form/page_routing_spec.rb

@ -64,7 +64,7 @@ RSpec.describe "Form Page Routing" do
it "does not show question if the answer could be inferred" do it "does not show question if the answer could be inferred" do
stub_request(:get, /api.postcodes.io/) stub_request(:get, /api.postcodes.io/)
.to_return(status: 200, body: "{\"status\":200,\"result\":{\"admin_district\":\"Manchester\", \"codes\":{\"admin_district\": \"E08000003\"}}}", headers: {}) .to_return(status: 200, body: "{\"status\":200,\"result\":{\"admin_district\":\"Manchester\", \"outcode\": \"M13\", \"incode\": \"1AA\", \"codes\":{\"admin_district\": \"E08000003\"}}}", headers: {})
visit("/lettings-logs/#{id}/property-postcode") visit("/lettings-logs/#{id}/property-postcode")
fill_in("lettings-log-postcode-full-field", with: "P0 5ST") fill_in("lettings-log-postcode-full-field", with: "P0 5ST")

6
spec/models/lettings_log_spec.rb

@ -1141,7 +1141,7 @@ RSpec.describe LettingsLog do
context "when saving addresses" do context "when saving addresses" do
before do before do
stub_request(:get, /api.postcodes.io/) stub_request(:get, /api.postcodes.io/)
.to_return(status: 200, body: "{\"status\":200,\"result\":{\"admin_district\":\"Manchester\",\"codes\":{\"admin_district\": \"E08000003\"}}}", headers: {}) .to_return(status: 200, body: "{\"status\":200,\"result\":{\"admin_district\":\"Manchester\", \"outcode\": \"M13\", \"incode\": \"1AA\", \"codes\":{\"admin_district\": \"E08000003\"}}}", headers: {})
end end
let!(:address_lettings_log) do let!(:address_lettings_log) do
@ -1229,7 +1229,7 @@ RSpec.describe LettingsLog do
context "when saving previous address" do context "when saving previous address" do
before do before do
stub_request(:get, /api.postcodes.io/) stub_request(:get, /api.postcodes.io/)
.to_return(status: 200, body: "{\"status\":200,\"result\":{\"admin_district\":\"Manchester\", \"codes\":{\"admin_district\": \"E08000003\"}}}", headers: {}) .to_return(status: 200, body: "{\"status\":200,\"result\":{\"admin_district\":\"Manchester\", \"outcode\": \"M13\", \"incode\": \"1AA\", \"codes\":{\"admin_district\": \"E08000003\"}}}", headers: {})
end end
let!(:address_lettings_log) do let!(:address_lettings_log) do
@ -1699,7 +1699,7 @@ RSpec.describe LettingsLog do
before do before do
stub_request(:get, /api.postcodes.io/) stub_request(:get, /api.postcodes.io/)
.to_return(status: 200, body: "{\"status\":200,\"result\":{\"admin_district\":\"Manchester\",\"codes\":{\"admin_district\": \"E08000003\"}}}", headers: {}) .to_return(status: 200, body: "{\"status\":200,\"result\":{\"admin_district\":\"Manchester\", \"outcode\": \"M13\", \"incode\": \"1AA\", \"codes\":{\"admin_district\": \"E08000003\"}}}", headers: {})
end end
it "correctly infers and saves la" do it "correctly infers and saves la" do

2
spec/models/location_spec.rb

@ -6,7 +6,7 @@ RSpec.describe Location, type: :model do
before do before do
stub_request(:get, /api.postcodes.io/) stub_request(:get, /api.postcodes.io/)
.to_return(status: 200, body: "{\"status\":200,\"result\":{\"admin_district\":\"Manchester\",\"codes\":{\"admin_district\": \"E08000003\"}}}", headers: {}) .to_return(status: 200, body: "{\"status\":200,\"result\":{\"admin_district\":\"Manchester\", \"outcode\": \"M13\", \"incode\": \"1AA\", \"codes\":{\"admin_district\": \"E08000003\"}}}", headers: {})
end end
it "belongs to an organisation" do it "belongs to an organisation" do

2
spec/requests/lettings_logs_controller_spec.rb

@ -721,7 +721,7 @@ RSpec.describe LettingsLogsController, type: :request do
before do before do
stub_request(:get, /api.postcodes.io/) stub_request(:get, /api.postcodes.io/)
.to_return(status: 200, body: "{\"status\":200,\"result\":{\"admin_district\":\"Manchester\", \"codes\":{\"admin_district\": \"E08000003\"}}}", headers: {}) .to_return(status: 200, body: "{\"status\":200,\"result\":{\"admin_district\":\"Manchester\", \"outcode\": \"M13\", \"incode\": \"1AA\", \"codes\":{\"admin_district\": \"E08000003\"}}}", headers: {})
sign_in user sign_in user
end end

Loading…
Cancel
Save