Browse Source

Merge branch 'main' into CLDC-3615-email-change-pending-banner

pull/2642/head
kosiakkatrina 2 years ago committed by GitHub
parent
commit
eb84d04610
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 2
      Gemfile.lock
  2. 17
      spec/services/postcode_service_spec.rb
  3. 27
      yarn.lock

2
Gemfile.lock

@ -314,7 +314,7 @@ GEM
byebug (~> 11.0) byebug (~> 11.0)
pry (>= 0.13, < 0.15) pry (>= 0.13, < 0.15)
public_suffix (5.0.4) public_suffix (5.0.4)
puma (5.6.8) puma (5.6.9)
nio4r (~> 2.0) nio4r (~> 2.0)
pundit (2.3.1) pundit (2.3.1)
activesupport (>= 3.0.0) activesupport (>= 3.0.0)

17
spec/services/postcode_service_spec.rb

@ -12,14 +12,10 @@ describe PostcodeService do
end end
describe "lookup" do describe "lookup" do
before do
Excon.defaults[:mock] = true
Excon.defaults[:stubs] = :local
end
context "when the request returns a success response" do context "when the request returns a success response" do
before do before do
Excon.stub({}, { body: '{"result": { "admin_district": "District", "codes": { "admin_district": "123" } } }', status: 200 }) WebMock.stub_request(:get, "https://api.postcodes.io/postcodes/A000AA")
.to_return(status: 200, body: "{\"status\":200,\"result\":{\"postcode\":\"A00 0AA\",\"admin_district\":\"District\",\"codes\":{\"admin_district\":\"123\"}}}", headers: {})
end end
it "returns the admin district and admin district code" do it "returns the admin district and admin district code" do
@ -31,7 +27,8 @@ describe PostcodeService do
context "when the request returns a not found response" do context "when the request returns a not found response" do
before do before do
Excon.stub({}, { status: 404 }) WebMock.stub_request(:get, "https://api.postcodes.io/postcodes/A000AA")
.to_return(status: 404, body: "{\"status\":404,\"error\":\"Postcode not found\"}", headers: {})
end end
it "returns nil" do it "returns nil" do
@ -47,7 +44,8 @@ describe PostcodeService do
context "when the request returns an error response" do context "when the request returns an error response" do
before do before do
Excon.stub({}, { body: "This is an error message that is not valid json", status: 500 }) WebMock.stub_request(:get, "https://api.postcodes.io/postcodes/A000AA")
.to_return(status: 500, body: "This is an error message that is not valid json", headers: {})
end end
it "returns nil" do it "returns nil" do
@ -63,7 +61,8 @@ describe PostcodeService do
context "when the request returns a success response that causes later errors" do context "when the request returns a success response that causes later errors" do
before do before do
Excon.stub({}, { body: '{"result": { "admin_district": "District" } }', status: 200 }) WebMock.stub_request(:get, "https://api.postcodes.io/postcodes/A000AA")
.to_return(status: 200, body: "{\"status\":200,\"result\":{\"admin_district\":\"Westminster\"", headers: {})
end end
it "returns nil" do it "returns nil" do

27
yarn.lock

@ -1792,7 +1792,7 @@ bl@^4.1.0:
inherits "^2.0.4" inherits "^2.0.4"
readable-stream "^3.4.0" readable-stream "^3.4.0"
body-parser@1.20.3: body-parser@1.20.3, body-parser@^1.20.2:
version "1.20.3" version "1.20.3"
resolved "https://registry.yarnpkg.com/body-parser/-/body-parser-1.20.3.tgz#1953431221c6fb5cd63c4b36d53fab0928e548c6" resolved "https://registry.yarnpkg.com/body-parser/-/body-parser-1.20.3.tgz#1953431221c6fb5cd63c4b36d53fab0928e548c6"
integrity sha512-7rAxByjUMqQ3/bHJy7D6OGXvx/MMc4IqBn/X0fcM1QUcAItpZrBEYhWGem+tzXH90c+G01ypMcYJBO9Y30203g== integrity sha512-7rAxByjUMqQ3/bHJy7D6OGXvx/MMc4IqBn/X0fcM1QUcAItpZrBEYhWGem+tzXH90c+G01ypMcYJBO9Y30203g==
@ -1810,24 +1810,6 @@ body-parser@1.20.3:
type-is "~1.6.18" type-is "~1.6.18"
unpipe "1.0.0" unpipe "1.0.0"
body-parser@^1.20.2:
version "1.20.2"
resolved "https://registry.yarnpkg.com/body-parser/-/body-parser-1.20.2.tgz#6feb0e21c4724d06de7ff38da36dad4f57a747fd"
integrity sha512-ml9pReCu3M61kGlqoTm2umSXTlRTuGTx0bfYj+uIUKKYycG5NtSbeetV3faSU6R7ajOPw0g/J1PvK4qNy7s5bA==
dependencies:
bytes "3.1.2"
content-type "~1.0.5"
debug "2.6.9"
depd "2.0.0"
destroy "1.2.0"
http-errors "2.0.0"
iconv-lite "0.4.24"
on-finished "2.4.1"
qs "6.11.0"
raw-body "2.5.2"
type-is "~1.6.18"
unpipe "1.0.0"
bootstrap@^5.1.3: bootstrap@^5.1.3:
version "5.3.3" version "5.3.3"
resolved "https://registry.yarnpkg.com/bootstrap/-/bootstrap-5.3.3.tgz#de35e1a765c897ac940021900fcbb831602bac38" resolved "https://registry.yarnpkg.com/bootstrap/-/bootstrap-5.3.3.tgz#de35e1a765c897ac940021900fcbb831602bac38"
@ -4825,13 +4807,6 @@ punycode@^2.1.0:
resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.3.1.tgz#027422e2faec0b25e1549c3e1bd8309b9133b6e5" resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.3.1.tgz#027422e2faec0b25e1549c3e1bd8309b9133b6e5"
integrity sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg== integrity sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==
qs@6.11.0:
version "6.11.0"
resolved "https://registry.yarnpkg.com/qs/-/qs-6.11.0.tgz#fd0d963446f7a65e1367e01abd85429453f0c37a"
integrity sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q==
dependencies:
side-channel "^1.0.4"
qs@6.13.0, qs@^6.4.0: qs@6.13.0, qs@^6.4.0:
version "6.13.0" version "6.13.0"
resolved "https://registry.yarnpkg.com/qs/-/qs-6.13.0.tgz#6ca3bd58439f7e245655798997787b0d88a51906" resolved "https://registry.yarnpkg.com/qs/-/qs-6.13.0.tgz#6ca3bd58439f7e245655798997787b0d88a51906"

Loading…
Cancel
Save