Merge pull request #4219 from alyssais/version_comparison

Fix comparison with Version::NULL on RHS
This commit is contained in:
Mike McQuaid 2018-05-28 20:35:49 +01:00 committed by GitHub
commit 517d147e33
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 0 deletions

View File

@ -144,6 +144,10 @@ describe Version do
expect(described_class.create("2.1.0-p194")).to be > nil expect(described_class.create("2.1.0-p194")).to be > nil
end end
it "can be compared against Version::NULL" do
expect(described_class.create("2.1.0-p194")).to be > Version::NULL
end
it "can be compared against strings" do it "can be compared against strings" do
expect(described_class.create("2.1.0-p194")).to be == "2.1.0-p194" expect(described_class.create("2.1.0-p194")).to be == "2.1.0-p194"
expect(described_class.create("1")).to be == 1 expect(described_class.create("1")).to be == 1

View File

@ -387,6 +387,7 @@ class Version
other = Version.new(other.to_s) if other.is_a? Integer other = Version.new(other.to_s) if other.is_a? Integer
return 1 if other.nil? return 1 if other.nil?
return 1 if other.respond_to?(:null?) && other.null?
return unless other.is_a?(Version) return unless other.is_a?(Version)
return 0 if version == other.version return 0 if version == other.version
return 1 if head? && !other.head? return 1 if head? && !other.head?