diff --git a/lib/pact_broker/api/decorators/embedded_version_decorator.rb b/lib/pact_broker/api/decorators/embedded_version_decorator.rb index 223a87744..37b444511 100644 --- a/lib/pact_broker/api/decorators/embedded_version_decorator.rb +++ b/lib/pact_broker/api/decorators/embedded_version_decorator.rb @@ -8,7 +8,6 @@ class EmbeddedVersionDecorator < BaseDecorator property :number if PactBroker.feature_enabled?(:branches) - property :branch property :build_url end diff --git a/lib/pact_broker/domain/version.rb b/lib/pact_broker/domain/version.rb index a685a6459..c63646055 100644 --- a/lib/pact_broker/domain/version.rb +++ b/lib/pact_broker/domain/version.rb @@ -330,6 +330,14 @@ def branch_names def tag_names tags.collect(&:name) end + + def branch + raise NotImplementedError + end + + def branch= branch + raise NotImplementedError + end end end end diff --git a/lib/pact_broker/test/http_test_data_builder.rb b/lib/pact_broker/test/http_test_data_builder.rb index 10b96e7ad..26a3a97af 100644 --- a/lib/pact_broker/test/http_test_data_builder.rb +++ b/lib/pact_broker/test/http_test_data_builder.rb @@ -286,6 +286,7 @@ def create_global_webhook_for_anything_published(uuid: nil, url: "https://postma "githubVerificationStatus" => "${pactbroker.githubVerificationStatus}", "providerVersionNumber" => "${pactbroker.providerVersionNumber}", "providerVersionTags" => "${pactbroker.providerVersionTags}", + "providerVersionBranch" => "${pactbroker.providerVersionBranch}", "canIMerge" => "${pactbroker.providerMainBranchGithubVerificationStatus}" } } diff --git a/lib/pact_broker/webhooks/pact_and_verification_parameters.rb b/lib/pact_broker/webhooks/pact_and_verification_parameters.rb index 063b86468..79cfec5e6 100644 --- a/lib/pact_broker/webhooks/pact_and_verification_parameters.rb +++ b/lib/pact_broker/webhooks/pact_and_verification_parameters.rb @@ -173,7 +173,7 @@ def provider_version_branch if webhook_context.key?(:provider_version_branch) webhook_context[:provider_version_branch] || "" else - verification&.provider_version&.branch || "" + verification&.provider_version&.branch_names&.last || "" end end diff --git a/script/data/webhook.rb b/script/data/webhook.rb index 80e439051..9cb46bdd9 100755 --- a/script/data/webhook.rb +++ b/script/data/webhook.rb @@ -7,13 +7,23 @@ td = PactBroker::Test::HttpTestDataBuilder.new(base_url) td.delete_webhook(uuid: "7a5da39c-8e50-4cc9-ae16-dfa5be043e8c") - .create_global_webhook_for_contract_changed(uuid: "7a5da39c-8e50-4cc9-ae16-dfa5be043e8c") + .create_global_webhook_for_anything_published(uuid: "7a5da39c-8e50-4cc9-ae16-dfa5be043e8c") .delete_pacticipant("foo-consumer") .delete_pacticipant("bar-provider") .create_pacticipant("foo-consumer") .create_pacticipant("bar-provider") .publish_pact(consumer: "foo-consumer", consumer_version: "1", provider: "bar-provider", content_id: "111", tag: "main") - + .get_pacts_for_verification( + provider: "bar-provider", + provider_version_branch: "main", + consumer_version_selectors: [{ mainBranch: true }] + ) + .verify_pact( + index: 0, + provider_version_branch: "main", + provider_version: "1", + success: true + ) rescue StandardError => e puts "#{e.class} #{e.message}" diff --git a/spec/lib/pact_broker/versions/service_spec.rb b/spec/lib/pact_broker/versions/service_spec.rb index 4136182bf..ea540887e 100644 --- a/spec/lib/pact_broker/versions/service_spec.rb +++ b/spec/lib/pact_broker/versions/service_spec.rb @@ -25,7 +25,7 @@ module Versions it "does not set the branch" do subject - expect(td.find_version(pacticipant_name, version_number).branch).to be_nil + expect(td.find_version(pacticipant_name, version_number).branch_names).to be_empty end end @@ -51,7 +51,7 @@ module Versions it "does not set the branch" do subject - expect(td.find_version(pacticipant_name, version_number).branch).to be_nil + expect(td.find_version(pacticipant_name, version_number).branch_names).to be_empty end end @@ -71,7 +71,7 @@ module Versions it "does not set the branch" do subject - expect(td.find_version(pacticipant_name, version_number).branch).to be_nil + expect(td.find_version(pacticipant_name, version_number).branch_names).to be_empty end end diff --git a/spec/lib/pact_broker/webhooks/render_spec.rb b/spec/lib/pact_broker/webhooks/render_spec.rb index e9b905a67..cec3c0775 100644 --- a/spec/lib/pact_broker/webhooks/render_spec.rb +++ b/spec/lib/pact_broker/webhooks/render_spec.rb @@ -71,7 +71,7 @@ module Webhooks end let(:provider_version) do - double("version", tags: provider_tags, branch: "provider-branch") + double("version", tags: provider_tags, branch_names: ["foo-branch", "provider-branch"]) end let(:consumer_version) do