From a8d389fc3b564cc02f26d39e55363f87deaf7a2c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 23 Sep 2024 09:02:00 +0100 Subject: [PATCH 1/2] Bump puma from 5.6.8 to 5.6.9 (#2654) Bumps [puma](https://github.com/puma/puma) from 5.6.8 to 5.6.9. - [Release notes](https://github.com/puma/puma/releases) - [Changelog](https://github.com/puma/puma/blob/master/History.md) - [Commits](https://github.com/puma/puma/compare/v5.6.8...v5.6.9) --- updated-dependencies: - dependency-name: puma dependency-type: direct:production ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index cdf923ae0..43d9374d1 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -314,7 +314,7 @@ GEM byebug (~> 11.0) pry (>= 0.13, < 0.15) public_suffix (5.0.4) - puma (5.6.8) + puma (5.6.9) nio4r (~> 2.0) pundit (2.3.1) activesupport (>= 3.0.0) From 204e022c8f8aac274f09369de89166ce8b1e840b Mon Sep 17 00:00:00 2001 From: kosiakkatrina <54268893+kosiakkatrina@users.noreply.github.com> Date: Mon, 23 Sep 2024 09:58:23 +0100 Subject: [PATCH 2/2] Refactor postcode tests to use webmock stubs (#2651) --- spec/services/postcode_service_spec.rb | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/spec/services/postcode_service_spec.rb b/spec/services/postcode_service_spec.rb index abc61129f..4df809606 100644 --- a/spec/services/postcode_service_spec.rb +++ b/spec/services/postcode_service_spec.rb @@ -12,14 +12,10 @@ describe PostcodeService do end describe "lookup" do - before do - Excon.defaults[:mock] = true - Excon.defaults[:stubs] = :local - end - context "when the request returns a success response" 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 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 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 it "returns nil" do @@ -47,7 +44,8 @@ describe PostcodeService do context "when the request returns an error response" 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 it "returns nil" do @@ -63,7 +61,8 @@ describe PostcodeService do context "when the request returns a success response that causes later errors" 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 it "returns nil" do