Skip to content

Commit

Permalink
feat: renamed 'wip pacts' to 'pending pacts'
Browse files Browse the repository at this point in the history
  • Loading branch information
bethesque committed Aug 13, 2018
1 parent 11939ca commit 11a56b5
Show file tree
Hide file tree
Showing 11 changed files with 27 additions and 27 deletions.
4 changes: 2 additions & 2 deletions lib/pact_broker/api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ module PactBroker
add ['pacts', 'provider', :provider_name, 'latest', :tag], Api::Resources::LatestProviderPacts, {resource_name: "latest_tagged_provider_pact_publications"}
add ['pacts', 'latest'], Api::Resources::LatestPacts, {resource_name: "latest_pacts"}

# WIP pacts
add ['pacts', 'provider', :provider_name, 'wip'], Api::Resources::WipProviderPacts, {resource_name: "wip_provider_pact_publications"}
# Pending pacts
add ['pacts', 'provider', :provider_name, 'pending'], Api::Resources::PendingProviderPacts, {resource_name: "pending_provider_pact_publications"}

# Deprecated pact
add ['pact', 'provider', :provider_name, 'consumer', :consumer_name, 'version', :consumer_version_number], Api::Resources::Pact, {resource_name: "pact_publications", deprecated: "true"} # Deprecate, singular /pact
Expand Down
6 changes: 3 additions & 3 deletions lib/pact_broker/api/resources/index.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ def links
title: 'Webhooks',
templated: false
},
'beta:wip-provider-pacts' =>
'beta:pending-provider-pacts' =>
{
href: base_url + '/pacts/provider/{provider}/wip',
title: 'WIP pact versions for the specified provider',
href: base_url + '/pacts/provider/{provider}/pending',
title: 'Pending pact versions for the specified provider',
templated: true
},
'curies' =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
module PactBroker
module Api
module Resources
class WipProviderPacts < ProviderPacts
class PendingProviderPacts < ProviderPacts
private

def pacts
pact_service.find_wip_pact_versions_for_provider provider_name
pact_service.find_pending_pact_versions_for_provider provider_name
end

def resource_title
"WIP pact versions for the provider #{provider_name}"
"Pending pact versions for the provider #{provider_name}"
end
end
end
Expand Down
3 changes: 3 additions & 0 deletions lib/pact_broker/doc/views/pending-provider-pacts.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Pending Pacts

This feature is in beta. It allows pending pacts (pacts that have not yet been succesfully verified) to run against a provider without failing the build.
3 changes: 0 additions & 3 deletions lib/pact_broker/doc/views/wip-provider-pacts.markdown

This file was deleted.

2 changes: 1 addition & 1 deletion lib/pact_broker/pacts/repository.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def find_latest_pact_versions_for_provider provider_name, tag = nil
end
end

def find_wip_pact_versions_for_provider provider_name
def find_pending_pact_versions_for_provider provider_name
provider_id = pacticipant_repository.find_by_name(provider_name).id
pact_publication_ids = PactBroker::Matrix::HeadRow.where(provider_id: provider_id).exclude(success: true).select_for_subquery(:pact_publication_id)
AllPactPublications.where(id: pact_publication_ids).order_ignore_case(:consumer_name).order_append(:consumer_version_order).collect(&:to_domain)
Expand Down
4 changes: 2 additions & 2 deletions lib/pact_broker/pacts/service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ def find_latest_pact_versions_for_provider provider_name, options = {}
pact_repository.find_latest_pact_versions_for_provider provider_name, options[:tag]
end

def find_wip_pact_versions_for_provider provider_name
pact_repository.find_wip_pact_versions_for_provider provider_name
def find_pending_pact_versions_for_provider provider_name
pact_repository.find_pending_pact_versions_for_provider provider_name
end

def find_pact_versions_for_provider provider_name, options = {}
Expand Down
4 changes: 2 additions & 2 deletions spec/features/get_wip_provider_pacts_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
describe "Get WIP provider pacts" do
describe "Get pending provider pacts" do
subject { get path; last_response }

let(:last_response_body) { JSON.parse(subject.body, symbolize_names: true) }
Expand All @@ -13,7 +13,7 @@
.create_pact
end

let(:path) { "/pacts/provider/Provider/wip" }
let(:path) { "/pacts/provider/Provider/pending" }

it "returns a 200 HAL JSON response" do
expect(subject).to be_a_hal_json_success_response
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,28 @@
module PactBroker
module Api
module Resources
describe WipProviderPacts do
describe PendingProviderPacts do
before do
allow(PactBroker::Pacts::Service).to receive(:find_wip_pact_versions_for_provider).and_return(pacts)
allow(PactBroker::Pacts::Service).to receive(:find_pending_pact_versions_for_provider).and_return(pacts)
allow(PactBroker::Api::Decorators::ProviderPactsDecorator).to receive(:new).and_return(decorator)
allow_any_instance_of(WipProviderPacts).to receive(:resource_exists?).and_return(provider)
allow_any_instance_of(PendingProviderPacts).to receive(:resource_exists?).and_return(provider)
end

let(:provider) { double('provider') }
let(:pacts) { double('pacts') }
let(:path) { '/pacts/provider/Bar/wip' }
let(:path) { '/pacts/provider/Bar/pending' }
let(:decorator) { instance_double('PactBroker::Api::Decorators::ProviderPactsDecorator') }

subject { get path; last_response }

it "finds the wip pacts for the provider" do
expect(PactBroker::Pacts::Service).to receive(:find_wip_pact_versions_for_provider).with("Bar")
it "finds the pending pacts for the provider" do
expect(PactBroker::Pacts::Service).to receive(:find_pending_pact_versions_for_provider).with("Bar")
subject
end

it "sets the correct resource title" do
expect(decorator).to receive(:to_json) do | options |
expect(options[:user_options][:title]).to eq "WIP pact versions for the provider Bar"
expect(options[:user_options][:title]).to eq "Pending pact versions for the provider Bar"
end
subject
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ module Pacts
describe Repository do
let(:td) { TestDataBuilder.new }

describe "find_wip_pact_versions_for_provider" do
subject { Repository.new.find_wip_pact_versions_for_provider("bar") }
describe "find_pending_pact_versions_for_provider" do
subject { Repository.new.find_pending_pact_versions_for_provider("bar") }

context "when the latest pact for a tag has been successfully verified" do
before do
Expand Down
4 changes: 2 additions & 2 deletions spec/service_consumers/provider_states_for_pact_ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
no_op
end

provider_state "the relation for retrieving WIP pacts exists in the index resource" do
provider_state "the relation for retrieving pending pacts exists in the index resource" do
no_op
end

provider_state "consumer-1 has a WIP pact with provider provider-1" do
provider_state "consumer-1 has a pending pact with provider provider-1" do
set_up do
TestDataBuilder.new
.create_provider('provider-1')
Expand Down

0 comments on commit 11a56b5

Please sign in to comment.