Crowdin / Upload translations / upload-translations (push) Skipped
Historical data migration test / test (14-alpine) (push) Canceled after 0s
Historical data migration test / test (15-alpine) (push) Canceled after 0s
Historical data migration test / test (16-alpine) (push) Canceled after 0s
Historical data migration test / test (17-alpine) (push) Canceled after 0s
Bundler Audit / security (push) Canceled after 0s
Haml Linting / lint (push) Canceled after 0s
JavaScript Linting / lint (push) Canceled after 0s
Ruby Linting / lint (push) Canceled after 0s
JavaScript Testing / test (push) Canceled after 0s
Ruby Testing / build (production) (push) Canceled after 0s
Ruby Testing / test (.ruby-version) (push) Canceled after 0s
Ruby Testing / test (3.3) (push) Canceled after 0s
Ruby Testing / test (3.4) (push) Canceled after 0s
Ruby Testing / End to End testing (.ruby-version) (push) Canceled after 0s
Ruby Testing / End to End testing (3.3) (push) Canceled after 0s
Ruby Testing / End to End testing (3.4) (push) Canceled after 0s
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:7.17.29) (push) Canceled after 0s
Check i18n / check-i18n (push) Canceled after 0s
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (javascript) (push) Canceled after 0s
CodeQL / Analyze (ruby) (push) Canceled after 0s
Ruby Testing / Elastic Search integration testing (.ruby-version, opensearchproject/opensearch:2) (push) Canceled after 0s
Ruby Testing / Elastic Search integration testing (3.3, docker.elastic.co/elasticsearch/elasticsearch:7.17.29) (push) Canceled after 0s
Ruby Testing / Elastic Search integration testing (3.4, docker.elastic.co/elasticsearch/elasticsearch:7.17.29) (push) Canceled after 0s
Check formatting / lint (push) Canceled after 0s
CSS Linting / lint (push) Canceled after 0s
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:8.19.2) (push) Canceled after 0s
Chromatic / Check for relevant changes (push) Canceled after 0s
Chromatic / Run Chromatic (push) Canceled after 0s
Snapshot of upstream tag v4.7.3 (commit 8ff11c2bb7b9f0714e947b10fa3629c6542c7121) from https://github.com/mastodon/mastodon, unmodified.
135 lines
3.6 KiB
Ruby
135 lines
3.6 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
require 'rails_helper'
|
|
|
|
RSpec.describe Admin::SystemCheck::SoftwareVersionCheck do
|
|
include RoutingHelper
|
|
|
|
subject(:check) { described_class.new(user) }
|
|
|
|
let(:user) { Fabricate(:user) }
|
|
|
|
describe 'skip?' do
|
|
context 'when user cannot view devops' do
|
|
before { allow(user).to receive(:can?).with(:view_devops).and_return(false) }
|
|
|
|
it 'returns true' do
|
|
expect(check.skip?).to be true
|
|
end
|
|
end
|
|
|
|
context 'when user can view devops' do
|
|
before { allow(user).to receive(:can?).with(:view_devops).and_return(true) }
|
|
|
|
it 'returns false' do
|
|
expect(check.skip?).to be false
|
|
end
|
|
|
|
context 'when checks are disabled' do
|
|
around do |example|
|
|
original = Rails.configuration.x.mastodon.software_update_url
|
|
Rails.configuration.x.mastodon.software_update_url = ''
|
|
example.run
|
|
Rails.configuration.x.mastodon.software_update_url = original
|
|
end
|
|
|
|
it 'returns true' do
|
|
expect(check.skip?).to be true
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
describe 'pass?' do
|
|
context 'when there is no known update' do
|
|
it 'returns true' do
|
|
expect(check.pass?).to be true
|
|
end
|
|
end
|
|
|
|
context 'when there is a non-urgent major release' do
|
|
before do
|
|
Fabricate(:software_update, version: '99.99.99', type: 'major', urgent: false)
|
|
end
|
|
|
|
it 'returns false' do
|
|
expect(check.pass?).to be false
|
|
end
|
|
end
|
|
|
|
context 'when there is an urgent major release' do
|
|
before do
|
|
Fabricate(:software_update, version: '99.99.99', type: 'major', urgent: true)
|
|
end
|
|
|
|
it 'returns false' do
|
|
expect(check.pass?).to be false
|
|
end
|
|
end
|
|
|
|
context 'when there is an urgent minor release' do
|
|
before do
|
|
Fabricate(:software_update, version: '99.99.99', type: 'minor', urgent: true)
|
|
end
|
|
|
|
it 'returns false' do
|
|
expect(check.pass?).to be false
|
|
end
|
|
end
|
|
|
|
context 'when there is an urgent patch release' do
|
|
before do
|
|
Fabricate(:software_update, version: '99.99.99', type: 'patch', urgent: true)
|
|
end
|
|
|
|
it 'returns false' do
|
|
expect(check.pass?).to be false
|
|
end
|
|
end
|
|
|
|
context 'when there is a non-urgent patch release' do
|
|
before do
|
|
Fabricate(:software_update, version: '99.99.99', type: 'patch', urgent: false)
|
|
end
|
|
|
|
it 'returns false' do
|
|
expect(check.pass?).to be false
|
|
end
|
|
end
|
|
end
|
|
|
|
describe 'message' do
|
|
context 'when there is a non-urgent patch release pending' do
|
|
before do
|
|
Fabricate(:software_update, version: '99.99.99', type: 'patch', urgent: false)
|
|
end
|
|
|
|
it 'sends class name symbol to message instance' do
|
|
allow(Admin::SystemCheck::Message).to receive(:new)
|
|
.with(:software_version_patch_check, anything, anything)
|
|
|
|
check.message
|
|
|
|
expect(Admin::SystemCheck::Message).to have_received(:new)
|
|
.with(:software_version_patch_check, nil, admin_software_updates_path)
|
|
end
|
|
end
|
|
|
|
context 'when there is an urgent patch release pending' do
|
|
before do
|
|
Fabricate(:software_update, version: '99.99.99', type: 'patch', urgent: true)
|
|
end
|
|
|
|
it 'sends class name symbol to message instance' do
|
|
allow(Admin::SystemCheck::Message).to receive(:new)
|
|
.with(:software_version_critical_check, anything, anything, anything)
|
|
|
|
check.message
|
|
|
|
expect(Admin::SystemCheck::Message).to have_received(:new)
|
|
.with(:software_version_critical_check, nil, admin_software_updates_path, critical: true)
|
|
end
|
|
end
|
|
end
|
|
end
|