1
0
Fork 0
forked from gitea/nas

Merge commit 'b805b7f021' into kb_migration_development

This commit is contained in:
KMY 2023-05-19 19:06:31 +09:00
commit 8c863323c1
5 changed files with 63 additions and 11 deletions

View file

@ -0,0 +1,34 @@
# frozen_string_literal: true
require 'rails_helper'
require 'mastodon/migration_warning'
describe Mastodon::MigrationWarning do
describe 'migration_duration_warning' do
before do
allow(migration).to receive(:valid_environment?).and_return(true)
allow(migration).to receive(:sleep).with(1)
end
let(:migration) { Class.new(ActiveRecord::Migration[6.1]).extend(described_class) }
context 'with the default message' do
it 'warns about long migrations' do
expectation = expect { migration.migration_duration_warning }
expectation.to output(/interrupt this migration/).to_stdout
expectation.to output(/Continuing in 5/).to_stdout
end
end
context 'with an additional message' do
it 'warns about long migrations' do
expectation = expect { migration.migration_duration_warning('Get ready for it') }
expectation.to output(/interrupt this migration/).to_stdout
expectation.to output(/Get ready for it/).to_stdout
expectation.to output(/Continuing in 5/).to_stdout
end
end
end
end

View file

@ -21,6 +21,27 @@ RSpec.describe BackupService, type: :service do
end
end
context 'when the user has an avatar and header' do
before do
user.account.update!(avatar: attachment_fixture('avatar.gif'))
user.account.update!(header: attachment_fixture('emojo.png'))
end
it 'stores them as expected' do
service_call
json = Oj.load(read_zip_file(backup, 'actor.json'))
avatar_path = json.dig('icon', 'url')
header_path = json.dig('image', 'url')
expect(avatar_path).to_not be_nil
expect(header_path).to_not be_nil
expect(read_zip_file(backup, avatar_path)).to be_present
expect(read_zip_file(backup, header_path)).to be_present
end
end
it 'marks the backup as processed' do
expect { service_call }.to change(backup, :processed).from(false).to(true)
end