outdated_state: omit 0. and 1. versions

This commit is contained in:
Simon Legner 2022-02-21 19:46:04 +01:00
parent 1e61abf275
commit 200e39ce90
2 changed files with 7 additions and 1 deletions

View file

@ -203,6 +203,8 @@ module Docs
[0, 1].each do |i|
break if i >= scraper_parts.length or i >= latest_parts.length
return 'Outdated major version' if i == 0 and latest_parts[i] > scraper_parts[i]
return 'Outdated major version' if i == 1 and latest_parts[i] > scraper_parts[i] and latest_parts[0] == 0 and scraper_parts[0] == 0
return 'Outdated major version' if i == 1 and latest_parts[i] > scraper_parts[i] and latest_parts[0] == 1 and scraper_parts[0] == 1
return 'Outdated minor version' if i == 1 and latest_parts[i] > scraper_parts[i]
return 'Up-to-date' if latest_parts[i] < scraper_parts[i]
end

View file

@ -390,12 +390,16 @@ class DocsDocTest < MiniTest::Spec
it "compares versions" do
instance = doc.versions.first.new
assert_equal "Up-to-date", instance.outdated_state('0.0.2', '0.0.3')
assert_equal "Outdated major version", instance.outdated_state('0.2', '0.3')
assert_equal 'Up-to-date', instance.outdated_state('1', '1')
assert_equal 'Up-to-date', instance.outdated_state('1.2', '1.2')
assert_equal 'Up-to-date', instance.outdated_state('1.2.2', '1.2.2')
assert_equal 'Up-to-date', instance.outdated_state('1.2.2', '1.2.3')
assert_equal "Outdated major version", instance.outdated_state('1', '2')
assert_equal "Outdated minor version", instance.outdated_state('1.2', '1.3')
assert_equal "Up-to-date", instance.outdated_state('1.0.2', '1.0.3')
assert_equal "Outdated major version", instance.outdated_state('1.2', '1.3')
assert_equal "Outdated minor version", instance.outdated_state('2.2', '2.3')
assert_equal "Outdated major version", instance.outdated_state('9', '10')
assert_equal "Outdated major version", instance.outdated_state('99', '101')
assert_equal 'Up-to-date', instance.outdated_state('2006-01-02', '2006-01-03')