Skip to content

Commit

Permalink
fix: return correct "latest" verification when a verification has bee…
Browse files Browse the repository at this point in the history
…n published for a pact with a revision
  • Loading branch information
bethesque committed Sep 18, 2017
1 parent 56f0d67 commit f2b4c9f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/pact_broker/domain/verification.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def untagged
end

def latest
reverse_order(:consumer_version_order, :number).limit(1)
reverse_order(:consumer_version_order, :revision_number, :number).limit(1)
end
end

Expand Down
19 changes: 19 additions & 0 deletions spec/lib/pact_broker/verifications/repository_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,25 @@ module Verifications
end

describe "#find_latest_verification_for" do
context "when there is a revision" do
before do
TestDataBuilder.new
.create_provider("Provider1")
.create_consumer("Consumer1")
.create_consumer_version("1.2.3")
.create_pact
.create_verification(number: 1, provider_version: "2.3.4")
.revise_pact
.create_verification(number: 1, provider_version: "7.8.9")
end

subject { Repository.new.find_latest_verification_for("Consumer1", "Provider1")}

it "finds the latest verifications for the given consumer version" do
expect(subject.provider_version).to eq "7.8.9"
end
end

context "when no tag is specified" do
before do
TestDataBuilder.new
Expand Down

0 comments on commit f2b4c9f

Please sign in to comment.