mirror of
https://github.com/Freika/dawarich.git
synced 2026-01-10 17:21:38 -05:00
Fix a bug where rc version was being checked as a stable release
This commit is contained in:
parent
043e9f873a
commit
f60c93ee4f
3 changed files with 14 additions and 1 deletions
|
|
@ -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 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 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
|
# 0.23.3 - 2025-01-21
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,10 @@ class CheckAppVersion
|
||||||
|
|
||||||
def latest_version
|
def latest_version
|
||||||
Rails.cache.fetch(VERSION_CACHE_KEY, expires_in: 6.hours) do
|
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
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,15 @@ RSpec.describe CheckAppVersion do
|
||||||
it { is_expected.to be true }
|
it { is_expected.to be true }
|
||||||
end
|
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
|
context 'when request fails' do
|
||||||
before do
|
before do
|
||||||
allow(Net::HTTP).to receive(:get).and_raise(StandardError)
|
allow(Net::HTTP).to receive(:get).and_raise(StandardError)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue