Fix argumenterror for invalid semver database versions

[ci skip]
pull/6698/head
Oliver Günther 6 years ago
parent b3ac00b3e4
commit be6514208e
No known key found for this signature in database
GPG Key ID: 88872239EB414F99
  1. 3
      lib/open_project/database.rb
  2. 5
      spec/lib/database_spec.rb

@ -139,6 +139,9 @@ module OpenProject
def self.semantic_version(version_string = self.version)
Semantic::Version.new version_string
rescue ArgumentError
# Cut anything behind the -
Semantic::Version.new version_string.gsub(/\-.+$/, '')
end
def self.numeric_version

@ -44,6 +44,11 @@ describe OpenProject::Database do
version3 = OpenProject::Database.semantic_version '10.1.26-MariaDB-0+deb9u1'
expect(version3.major).to eq 10
version4 = OpenProject::Database.semantic_version '5.7.23-0ubuntu0.16.04.1'
expect(version4.major).to eq 5
# Cuts the build if its invalid semver
expect(version4.build).to be_nil
end
it 'should be able to use the helper methods' do

Loading…
Cancel
Save