From 6e67d3a6096dfeb622f923ada991780e9e838de0 Mon Sep 17 00:00:00 2001 From: Beth Skurrie Date: Fri, 16 Aug 2019 14:25:09 +1000 Subject: [PATCH] refactor: rename latest_verification --- lib/pact_broker/index/service.rb | 2 +- lib/pact_broker/matrix/aggregated_row.rb | 7 ++++++- spec/lib/pact_broker/matrix/aggregated_row_spec.rb | 4 ++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/pact_broker/index/service.rb b/lib/pact_broker/index/service.rb index e36c7ffca..325ce72eb 100644 --- a/lib/pact_broker/index/service.rb +++ b/lib/pact_broker/index/service.rb @@ -42,7 +42,7 @@ def self.find_index_items options = {} row.provider, row.pact, row.overall_latest?, - row.latest_verification, + row.latest_verification_for_pseudo_branch, row.webhooks, row.latest_triggered_webhooks, options[:tags] ? row.consumer_head_tag_names : [], diff --git a/lib/pact_broker/matrix/aggregated_row.rb b/lib/pact_broker/matrix/aggregated_row.rb index 14d8aceb3..48a649141 100644 --- a/lib/pact_broker/matrix/aggregated_row.rb +++ b/lib/pact_broker/matrix/aggregated_row.rb @@ -24,7 +24,12 @@ def overall_latest? # If this comes back nil, it won't be "cached", but it's a reasonably # quick query, so it's probably ok. - def latest_verification + # The collection of pacts that belong to the same tag can be considered + # a pseudo branch. Find the latest verification for each pseudo branch + # and return the most recent. If this pact is the most recent overall, + # and there were no verifications found for any of the tags, then + # return the most recent verification + def latest_verification_for_pseudo_branch @latest_verification ||= begin verification = matrix_rows.collect do | row| row.verification || latest_verification_for_consumer_version_tag(row) diff --git a/spec/lib/pact_broker/matrix/aggregated_row_spec.rb b/spec/lib/pact_broker/matrix/aggregated_row_spec.rb index 6092684a7..a47d0e7f0 100644 --- a/spec/lib/pact_broker/matrix/aggregated_row_spec.rb +++ b/spec/lib/pact_broker/matrix/aggregated_row_spec.rb @@ -3,7 +3,7 @@ module PactBroker module Matrix describe AggregatedRow do - describe "latest_verification" do + describe "latest_verification_for_pseudo_branch" do let(:row_1) do instance_double('PactBroker::Matrix::HeadRow', consumer_name: "Foo", @@ -27,7 +27,7 @@ module Matrix let(:rows) { [row_1, row_2] } let(:aggregated_row) { AggregatedRow.new(rows) } - subject { aggregated_row.latest_verification } + subject { aggregated_row.latest_verification_for_pseudo_branch } context "when the rows have verifications" do it "returns the verification with the largest id" do