Skip to content

Commit

Permalink
refactor: rename latest_verification
Browse files Browse the repository at this point in the history
  • Loading branch information
bethesque committed Aug 16, 2019
1 parent b9d229a commit 6e67d3a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/pact_broker/index/service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 : [],
Expand Down
7 changes: 6 additions & 1 deletion lib/pact_broker/matrix/aggregated_row.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions spec/lib/pact_broker/matrix/aggregated_row_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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
Expand Down

0 comments on commit 6e67d3a

Please sign in to comment.