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?
OpenStruct.new({
location_code: postcode_lookup.codes["admin_district"],
location_admin_district: postcode_lookup&.admin_district,
incode: postcode_lookup&.incode,
outcode: postcode_lookup&.outcode,
result?: postcode_lookup&.outcode&.present?,
location_admin_district: postcode_lookup.admin_district,
incode: postcode_lookup.incode,
outcode: postcode_lookup.outcode,
result?: postcode_lookup.outcode.present?,
})
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
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")
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
before do
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
let!(:address_lettings_log) do
@ -1229,7 +1229,7 @@ RSpec.describe LettingsLog do
context "when saving previous address" do
before do
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
let!(:address_lettings_log) do
@ -1699,7 +1699,7 @@ RSpec.describe LettingsLog do
before do
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
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
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
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
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
end

Loading…
Cancel
Save