From bea59518198db5f26c2843d0413b300f3ada3388 Mon Sep 17 00:00:00 2001 From: Beth Skurrie Date: Thu, 10 Oct 2019 08:36:13 +1100 Subject: [PATCH] feat: show more helpful error message when someone tries to get /all verifications for a pact --- lib/pact_broker/api/resources/verification.rb | 7 ++++++- .../api/resources/verification_spec.rb | 18 ++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 spec/lib/pact_broker/api/resources/verification_spec.rb diff --git a/lib/pact_broker/api/resources/verification.rb b/lib/pact_broker/api/resources/verification.rb index bd4ed4590..d550be927 100644 --- a/lib/pact_broker/api/resources/verification.rb +++ b/lib/pact_broker/api/resources/verification.rb @@ -24,7 +24,12 @@ def allowed_methods end def resource_exists? - !!verification + if identifier_from_path[:verification_number] == "all" + set_json_error_message("To see all the verifications for a pact, use the Matrix page") + false + else + !!verification + end end def to_json diff --git a/spec/lib/pact_broker/api/resources/verification_spec.rb b/spec/lib/pact_broker/api/resources/verification_spec.rb new file mode 100644 index 000000000..ffb0f2a45 --- /dev/null +++ b/spec/lib/pact_broker/api/resources/verification_spec.rb @@ -0,0 +1,18 @@ +require 'pact_broker/api/resources/verification' + +module PactBroker + module Api + module Resources + describe Verification do + context "when someone tries to get all the verifications for a pact" do + subject { get("/pacts/provider/Bar/consumer/Foo/pact-version/1/verification-results/all") } + + it "tells them to use the matrix" do + expect(subject.status).to eq 404 + expect(subject.body).to include "Matrix" + end + end + end + end + end +end