From 895b65af93fba07067499c9b37e26834b011ed4f Mon Sep 17 00:00:00 2001 From: Kevin Dew Date: Fri, 7 Feb 2020 22:37:29 +0000 Subject: [PATCH] Add stub_any_publishing_api_unreserve_path test helper This is one of the few stubbed methods that didn't have an any equivalent and thus was a source of surprise. --- CHANGELOG.md | 1 + lib/gds_api/test_helpers/publishing_api.rb | 4 ++++ test/test_helpers/publishing_api_test.rb | 9 +++++++++ 3 files changed, 14 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index eb67fd32..d1e2e4ea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ # Unreleased +* Add `stub_any_publishing_api_unreserve_path` test helper. * Fix Publishing API `stub_any_publishing_api_call` methods only operating on the V2 endpoint. diff --git a/lib/gds_api/test_helpers/publishing_api.rb b/lib/gds_api/test_helpers/publishing_api.rb index 1cbce180..c6f7ba87 100644 --- a/lib/gds_api/test_helpers/publishing_api.rb +++ b/lib/gds_api/test_helpers/publishing_api.rb @@ -640,6 +640,10 @@ def stub_publishing_api_unreserve_path_invalid(base_path, publishing_app = /.*/) stub_publishing_api_unreserve_path_with_code(base_path, publishing_app, 422) end + def stub_any_publishing_api_unreserve_path + stub_request(:delete, %r{\A#{PUBLISHING_API_ENDPOINT}/paths/}) + end + # Stub a PUT /publish-intent/:base_path request with the given base_path # and request body. # diff --git a/test/test_helpers/publishing_api_test.rb b/test/test_helpers/publishing_api_test.rb index 09d749e7..98d37566 100644 --- a/test/test_helpers/publishing_api_test.rb +++ b/test/test_helpers/publishing_api_test.rb @@ -427,6 +427,15 @@ end end + describe "#stub_any_publishing_api_unreserve_path" do + it "stubs a request to unreserve a path" do + stub_any_publishing_api_unreserve_path + + api_response = publishing_api.unreserve_path("/foo", "myapp") + assert_equal(api_response.code, 200) + end + end + describe "#stub_any_publishing_api_path_reservation" do it "stubs a request to reserve a path" do stub_any_publishing_api_path_reservation