Merge pull request #712 from Freika/fix/app-version-rc-check

Fix a bug where rc version was being checked as a stable release
This commit is contained in:
Evgenii Burmakin 2025-01-22 13:06:39 +01:00 committed by GitHub
commit 94712b5c96
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 14 additions and 1 deletions

View file

@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Fix authentication to `GET /api/v1/countries/visited_cities` with header `Authorization: Bearer YOUR_API_KEY` instead of `api_key` query param. #679
- Fix a bug where a gpx file with empty tracks was not being imported. #646
- Fix a bug where rc version was being checked as a stable release. #711
# 0.23.3 - 2025-01-21

View file

@ -17,7 +17,10 @@ class CheckAppVersion
def latest_version
Rails.cache.fetch(VERSION_CACHE_KEY, expires_in: 6.hours) do
JSON.parse(Net::HTTP.get(URI.parse(@repo_url)))[0]['name']
versions = JSON.parse(Net::HTTP.get(URI.parse(@repo_url)))
# Find first version that contains only numbers and dots
release_version = versions.find { |v| v['name'].match?(/^\d+\.\d+\.\d+$/) }
release_version ? release_version['name'] : APP_VERSION
end
end
end

View file

@ -29,6 +29,15 @@ RSpec.describe CheckAppVersion do
it { is_expected.to be true }
end
context 'when latest version is not a stable release' do
before do
stub_request(:any, 'https://api.github.com/repos/Freika/dawarich/tags')
.to_return(status: 200, body: '[{"name": "1.0.0-rc.1"}]', headers: {})
end
it { is_expected.to be false }
end
context 'when request fails' do
before do
allow(Net::HTTP).to receive(:get).and_raise(StandardError)