Skip to content

Commit bf30024

Browse files
committed
fix: do not parse the provider version as a semantic version when order_versions_by_date is true
fixes: pact-foundation#329
1 parent e2c424c commit bf30024

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

lib/pact_broker/api/contracts/verification_contract.rb

+2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ def valid_url? url
2525
end
2626

2727
def valid_version_number?(value)
28+
return true if PactBroker.configuration.order_versions_by_date
29+
2830
parsed_version_number = PactBroker.configuration.version_parser.call(value)
2931
!!parsed_version_number
3032
end

spec/lib/pact_broker/api/contracts/verification_contract_spec.rb

+18-4
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ module Contracts
1515
let(:success) { true }
1616
let(:provider_version) { "4.5.6" }
1717
let(:build_url) { 'http://foo' }
18+
let(:order_versions_by_date) { false }
1819

1920
def modify hash, options
2021
hash.delete(options.fetch(:without))
@@ -24,6 +25,7 @@ def modify hash, options
2425
describe "errors" do
2526

2627
before do
28+
allow(PactBroker.configuration).to receive(:order_versions_by_date).and_return(order_versions_by_date)
2729
subject.validate(params)
2830
end
2931

@@ -85,10 +87,22 @@ def modify hash, options
8587
end
8688
end
8789

88-
context "when the providerApplicationVersion is not a semantic version" do
89-
let(:provider_version) { "#" }
90-
it "has an error" do
91-
expect(subject.errors[:provider_version]).to include(match("#.*cannot be parsed"))
90+
context "when order_versions_by_date is true" do
91+
let(:order_versions_by_date) { true }
92+
93+
context "when the providerApplicationVersion is not a semantic version" do
94+
let(:provider_version) { "#" }
95+
its(:errors) { is_expected.to be_empty }
96+
end
97+
end
98+
99+
context "when order_versions_by_date is false" do
100+
context "when the providerApplicationVersion is not a semantic version" do
101+
let(:provider_version) { "#" }
102+
103+
it "has an error" do
104+
expect(subject.errors[:provider_version]).to include(match("#.*cannot be parsed"))
105+
end
92106
end
93107
end
94108
end

0 commit comments

Comments
 (0)