Skip to content

Commit

Permalink
feat: add endpoint to retrieve a pact version by its pact content sha
Browse files Browse the repository at this point in the history
  • Loading branch information
bethesque committed May 3, 2018
1 parent 955b9ea commit a519731
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/pact_broker/api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ module PactBroker

# Pacts
add ['pacts', 'provider', :provider_name, 'consumer', :consumer_name, 'version', :consumer_version_number], Api::Resources::Pact, {resource_name: "pact_publication"}
add ['pacts', 'provider', :provider_name, 'consumer', :consumer_name, 'pact-version', :pact_version_sha], Api::Resources::PactVersion, {resource_name: "pact_publication"}
add ['pacts', 'provider', :provider_name, 'consumer', :consumer_name, 'version', :consumer_version_number, 'previous-distinct'], Api::Resources::PreviousDistinctPactVersion, {resource_name: "previous_distinct_pact_version"}
add ['pacts', 'provider', :provider_name, 'consumer', :consumer_name, 'version', :consumer_version_number, 'diff', 'previous-distinct'], Api::Resources::PactContentDiff, {resource_name: "previous_distinct_pact_version_diff"}

Expand Down
13 changes: 13 additions & 0 deletions lib/pact_broker/api/resources/pact_version.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
require 'pact_broker/api/resources/pact'

module PactBroker
module Api
module Resources
class PactVersion < Pact
def allowed_methods
["GET"]
end
end
end
end
end
13 changes: 13 additions & 0 deletions spec/features/get_pact_version.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
describe "retrieving a pact" do
subject { get path; last_response }

context "when differing case is used in the consumer and provider names" do
let(:td) { TestDataBuilder.new }
let(:pact) { td.create_pact_with_hierarchy("Foo", "1", "Bar").and_return(:pact) }
let!(:path) { "/pacts/provider/Bar/consumer/Foo/pact-version/#{pact.pact_version_sha}" }

it "returns a 200 Success" do
expect(subject.status).to be 200
end
end
end

0 comments on commit a519731

Please sign in to comment.