0
0
Fork 0

Add coverage for malformed version cleanup in SoftwareUpdateCheckService, add helper query methods (#32876)

This commit is contained in:
Matt Jankowski 2024-11-14 09:03:57 -05:00 committed by GitHub
parent 62d65504f6
commit 766358e52b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 73 additions and 4 deletions

View file

@ -3,6 +3,60 @@
require 'rails_helper'
RSpec.describe SoftwareUpdate do
describe '#pending?' do
subject { described_class.new(version: update_version) }
before { allow(Mastodon::Version).to receive(:gem_version).and_return(Gem::Version.new(mastodon_version)) }
context 'when the runtime version is older than the update' do
let(:mastodon_version) { '4.0.0' }
let(:update_version) { '5.0.0' }
it { is_expected.to be_pending }
end
context 'when the runtime version is newer than the update' do
let(:mastodon_version) { '6.0.0' }
let(:update_version) { '5.0.0' }
it { is_expected.to_not be_pending }
end
context 'when the runtime version is same as the update' do
let(:mastodon_version) { '4.0.0' }
let(:update_version) { '4.0.0' }
it { is_expected.to_not be_pending }
end
end
describe '#outdated?' do
subject { described_class.new(version: update_version) }
before { allow(Mastodon::Version).to receive(:gem_version).and_return(Gem::Version.new(mastodon_version)) }
context 'when the runtime version is older than the update' do
let(:mastodon_version) { '4.0.0' }
let(:update_version) { '5.0.0' }
it { is_expected.to_not be_outdated }
end
context 'when the runtime version is newer than the update' do
let(:mastodon_version) { '6.0.0' }
let(:update_version) { '5.0.0' }
it { is_expected.to be_outdated }
end
context 'when the runtime version is same as the update' do
let(:mastodon_version) { '4.0.0' }
let(:update_version) { '4.0.0' }
it { is_expected.to be_outdated }
end
end
describe '.pending_to_a' do
before do
allow(Mastodon::Version).to receive(:gem_version).and_return(Gem::Version.new(mastodon_version))