Skip to content

Commit

Permalink
feat: show more helpful error message when someone tries to get /all …
Browse files Browse the repository at this point in the history
…verifications for a pact
  • Loading branch information
bethesque committed Oct 9, 2019
1 parent c1a76f5 commit bea5951
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/pact_broker/api/resources/verification.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 18 additions & 0 deletions spec/lib/pact_broker/api/resources/verification_spec.rb
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit bea5951

Please sign in to comment.