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

@ -101,8 +101,8 @@ class BackupService < BaseService
actor[:likes] = 'likes.json'
actor[:bookmarks] = 'bookmarks.json'
download_to_zip(tar, account.avatar, "avatar#{File.extname(account.avatar.path)}") if account.avatar.exists?
download_to_zip(tar, account.header, "header#{File.extname(account.header.path)}") if account.header.exists?
download_to_zip(zipfile, account.avatar, "avatar#{File.extname(account.avatar.path)}") if account.avatar.exists?
download_to_zip(zipfile, account.header, "header#{File.extname(account.header.path)}") if account.header.exists?
json = Oj.dump(actor)

View file

@ -73,7 +73,7 @@
"intl-messageformat": "^2.2.0",
"intl-relativeformat": "^6.4.3",
"js-yaml": "^4.1.0",
"jsdom": "^21.1.2",
"jsdom": "^22.0.0",
"lodash": "^4.17.21",
"mark-loader": "^0.1.6",
"marky": "^1.2.5",

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

View file

@ -2800,7 +2800,7 @@ acorn@^6.4.1:
resolved "https://registry.yarnpkg.com/acorn/-/acorn-6.4.1.tgz#531e58ba3f51b9dacb9a6646ca4debf5b14ca474"
integrity sha512-ZVA9k326Nwrj3Cj9jlh3wGFutC2ZornPNARZwsNYqQYgN0EsV2d53w5RN/co65Ohn4sUAUtb1rSUAOD6XN9idA==
acorn@^8.0.4, acorn@^8.1.0, acorn@^8.5.0, acorn@^8.8.0, acorn@^8.8.1, acorn@^8.8.2:
acorn@^8.0.4, acorn@^8.1.0, acorn@^8.5.0, acorn@^8.8.0, acorn@^8.8.1:
version "8.8.2"
resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.8.2.tgz#1b2f25db02af965399b9776b0c2c391276d37c4a"
integrity sha512-xjIYgE8HBrkpd/sJqOGNspf8uHG+NOHGOw6a/Urj8taM2EXfdNAH2oFcPeIFfsv3+kz/mJrS5VuMqbNLjCa2vw==
@ -7522,19 +7522,16 @@ jsdom@^20.0.0:
ws "^8.11.0"
xml-name-validator "^4.0.0"
jsdom@^21.1.2:
version "21.1.2"
resolved "https://registry.yarnpkg.com/jsdom/-/jsdom-21.1.2.tgz#6433f751b8718248d646af1cdf6662dc8a1ca7f9"
integrity sha512-sCpFmK2jv+1sjff4u7fzft+pUh2KSUbUrEHYHyfSIbGTIcmnjyp83qg6qLwdJ/I3LpTXx33ACxeRL7Lsyc6lGQ==
jsdom@^22.0.0:
version "22.0.0"
resolved "https://registry.yarnpkg.com/jsdom/-/jsdom-22.0.0.tgz#3295c6992c70089c4b8f5cf060489fddf7ee9816"
integrity sha512-p5ZTEb5h+O+iU02t0GfEjAnkdYPrQSkfuTSMkMYyIoMvUNEHsbG0bHHbfXIcfTqD2UfvjQX7mmgiFsyRwGscVw==
dependencies:
abab "^2.0.6"
acorn "^8.8.2"
acorn-globals "^7.0.0"
cssstyle "^3.0.0"
data-urls "^4.0.0"
decimal.js "^10.4.3"
domexception "^4.0.0"
escodegen "^2.0.0"
form-data "^4.0.0"
html-encoding-sniffer "^3.0.0"
http-proxy-agent "^5.0.0"