diff --git a/lib/pact_broker/pacts/repository.rb b/lib/pact_broker/pacts/repository.rb index 6f2b1be36..4b1d12577 100644 --- a/lib/pact_broker/pacts/repository.rb +++ b/lib/pact_broker/pacts/repository.rb @@ -559,6 +559,7 @@ def find_successfully_verified_head_pacts_by_provider_tag(provider_id, provider_ verifications_join = { pact_version_id: :pact_version_id, Sequel[:verifications][:success] => true, + Sequel[:verifications][:wip] => false, Sequel[:verifications][:provider_id] => provider_id } tags_join = { diff --git a/lib/pact_broker/test/test_data_builder.rb b/lib/pact_broker/test/test_data_builder.rb index 91f8a42bb..f9ae76407 100644 --- a/lib/pact_broker/test/test_data_builder.rb +++ b/lib/pact_broker/test/test_data_builder.rb @@ -316,7 +316,7 @@ def create_verification parameters = {} parameters.delete(:comment) tag_names = [parameters.delete(:tag_names), parameters.delete(:tag_name)].flatten.compact provider_version_number = parameters[:provider_version] || '4.5.6' - default_parameters = {success: true, number: 1, test_results: {some: 'results'}} + default_parameters = { success: true, number: 1, test_results: {some: 'results'}, wip: false } default_parameters[:execution_date] = @now if @now parameters = default_parameters.merge(parameters) parameters.delete(:provider_version) diff --git a/spec/lib/pact_broker/pacts/repository_find_wip_pact_versions_for_provider_spec.rb b/spec/lib/pact_broker/pacts/repository_find_wip_pact_versions_for_provider_spec.rb index 55b499a53..cb0f33568 100644 --- a/spec/lib/pact_broker/pacts/repository_find_wip_pact_versions_for_provider_spec.rb +++ b/spec/lib/pact_broker/pacts/repository_find_wip_pact_versions_for_provider_spec.rb @@ -3,8 +3,6 @@ module PactBroker module Pacts describe Repository do - let(:td) { TestDataBuilder.new } - describe "find_wip_pact_versions_for_provider" do let(:provider_tags) { %w[dev] } let(:options) { { include_wip_pacts_since: include_wip_pacts_since } } @@ -73,6 +71,28 @@ module Pacts end end + context "when the latest pact for a tag has been successfully verified by the given provider tag but it was a WIP verification" do + before do + td.create_provider("bar") + .create_provider_version("333") + .create_provider_version_tag("dev") + .add_day + .create_pact_with_hierarchy("foo", "1", "bar") + .comment("above not included because it's not the latest dev") + .create_consumer_version("2") + .create_consumer_version_tag("feat-1") + .create_pact + .create_verification(wip: true, success: true, provider_version: "3", tag_names: %w[dev]) + end + + let(:provider_tags) { %w[dev] } + + it "it is included" do + expect(subject[0].consumer_name).to eq "foo" + expect(subject[0].consumer_version_number).to eq "2" + end + end + context "when the latest pact for a tag has been successfully verified by one of the given provider tags, but not the other" do before do td.create_provider("bar") @@ -145,6 +165,8 @@ module Pacts end end + + context "when the latest pact for a tag has not been verified" do before do td.create_provider("bar")