diff --git a/lib/pact_broker/integrations/service.rb b/lib/pact_broker/integrations/service.rb index 0289ae1dc..4d4dbc1b7 100644 --- a/lib/pact_broker/integrations/service.rb +++ b/lib/pact_broker/integrations/service.rb @@ -20,7 +20,7 @@ def self.delete(consumer_name, provider_name) version_repository.delete_orphan_versions(consumer, provider) pacticipant_service.delete_if_orphan(consumer) - pacticipant_service.delete_if_orphan(provider) + pacticipant_service.delete_if_orphan(provider) unless consumer == provider end end end diff --git a/spec/lib/pact_broker/integrations/service_spec.rb b/spec/lib/pact_broker/integrations/service_spec.rb index 33d93a6eb..0ab33ec1c 100644 --- a/spec/lib/pact_broker/integrations/service_spec.rb +++ b/spec/lib/pact_broker/integrations/service_spec.rb @@ -208,6 +208,19 @@ module Integrations expect { subject }.to change { PactBroker::Domain::Version.count } end end + + context "when a pacticipant has a pact with itself... I wouldn't have believed it unless I'd seen it..." do + before do + td.create_consumer("Foo") + .use_provider("Foo") + .create_consumer_version("1") + .create_pact + end + + it "doesn't blow up" do + Service.delete("Foo", "Foo") + end + end end end end