Merge pull request #327 from kmycode/upstream-20231204

Upstream 20231204
This commit is contained in:
KMY(雪あすか) 2023-12-04 13:00:02 +09:00 committed by GitHub
commit 831fa2d00a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
179 changed files with 1036 additions and 775 deletions

View file

@ -59,10 +59,10 @@ describe ContentSecurityPolicy do
end
end
describe '#media_host' do
describe '#media_hosts' do
context 'when there is no configured CDN' do
it 'defaults to using the assets_host value' do
expect(subject.media_host).to eq(subject.assets_host)
expect(subject.media_hosts).to contain_exactly(subject.assets_host)
end
end
@ -74,7 +74,7 @@ describe ContentSecurityPolicy do
end
it 'uses the s3 alias host value' do
expect(subject.media_host).to eq 'https://asset-host.s3-alias.example'
expect(subject.media_hosts).to contain_exactly(subject.assets_host, 'https://asset-host.s3-alias.example')
end
end
@ -86,7 +86,7 @@ describe ContentSecurityPolicy do
end
it 'uses the s3 alias host value and preserves the path' do
expect(subject.media_host).to eq 'https://asset-host.s3-alias.example/pathname/'
expect(subject.media_hosts).to contain_exactly(subject.assets_host, 'https://asset-host.s3-alias.example/pathname/')
end
end
@ -98,7 +98,7 @@ describe ContentSecurityPolicy do
end
it 'uses the s3 cloudfront host value' do
expect(subject.media_host).to eq 'https://asset-host.s3-cloudfront.example'
expect(subject.media_hosts).to contain_exactly(subject.assets_host, 'https://asset-host.s3-cloudfront.example')
end
end
@ -110,7 +110,7 @@ describe ContentSecurityPolicy do
end
it 'uses the azure alias host value' do
expect(subject.media_host).to eq 'https://asset-host.azure-alias.example'
expect(subject.media_hosts).to contain_exactly(subject.assets_host, 'https://asset-host.azure-alias.example')
end
end
@ -122,7 +122,7 @@ describe ContentSecurityPolicy do
end
it 'uses the s3 hostname host value' do
expect(subject.media_host).to eq 'https://asset-host.s3.example'
expect(subject.media_hosts).to contain_exactly(subject.assets_host, 'https://asset-host.s3.example')
end
end
end

View file

@ -6,6 +6,8 @@ require 'mastodon/cli/accounts'
describe Mastodon::CLI::Accounts do
let(:cli) { described_class.new }
it_behaves_like 'CLI Command'
# `parallelize_with_progress` cannot run in transactions, so instead,
# stub it with an alternative implementation that runs sequentially
# and can run in transactions.
@ -24,12 +26,6 @@ describe Mastodon::CLI::Accounts do
end
end
describe '.exit_on_failure?' do
it 'returns true' do
expect(described_class.exit_on_failure?).to be true
end
end
describe '#create' do
shared_examples 'a new user with given email address and username' do
it 'creates a new user with the specified email address' do

View file

@ -6,11 +6,7 @@ require 'mastodon/cli/cache'
describe Mastodon::CLI::Cache do
let(:cli) { described_class.new }
describe '.exit_on_failure?' do
it 'returns true' do
expect(described_class.exit_on_failure?).to be true
end
end
it_behaves_like 'CLI Command'
describe '#clear' do
before { allow(Rails.cache).to receive(:clear) }

View file

@ -6,11 +6,7 @@ require 'mastodon/cli/canonical_email_blocks'
describe Mastodon::CLI::CanonicalEmailBlocks do
let(:cli) { described_class.new }
describe '.exit_on_failure?' do
it 'returns true' do
expect(described_class.exit_on_failure?).to be true
end
end
it_behaves_like 'CLI Command'
describe '#find' do
let(:arguments) { ['user@example.com'] }

View file

@ -4,9 +4,5 @@ require 'rails_helper'
require 'mastodon/cli/domains'
describe Mastodon::CLI::Domains do
describe '.exit_on_failure?' do
it 'returns true' do
expect(described_class.exit_on_failure?).to be true
end
end
it_behaves_like 'CLI Command'
end

View file

@ -4,9 +4,5 @@ require 'rails_helper'
require 'mastodon/cli/email_domain_blocks'
describe Mastodon::CLI::EmailDomainBlocks do
describe '.exit_on_failure?' do
it 'returns true' do
expect(described_class.exit_on_failure?).to be true
end
end
it_behaves_like 'CLI Command'
end

View file

@ -4,9 +4,5 @@ require 'rails_helper'
require 'mastodon/cli/emoji'
describe Mastodon::CLI::Emoji do
describe '.exit_on_failure?' do
it 'returns true' do
expect(described_class.exit_on_failure?).to be true
end
end
it_behaves_like 'CLI Command'
end

View file

@ -6,11 +6,7 @@ require 'mastodon/cli/feeds'
describe Mastodon::CLI::Feeds do
let(:cli) { described_class.new }
describe '.exit_on_failure?' do
it 'returns true' do
expect(described_class.exit_on_failure?).to be true
end
end
it_behaves_like 'CLI Command'
describe '#build' do
before { Fabricate(:account) }

View file

@ -6,11 +6,7 @@ require 'mastodon/cli/ip_blocks'
describe Mastodon::CLI::IpBlocks do
let(:cli) { described_class.new }
describe '.exit_on_failure?' do
it 'returns true' do
expect(described_class.exit_on_failure?).to be true
end
end
it_behaves_like 'CLI Command'
describe '#add' do
let(:ip_list) do

View file

@ -4,11 +4,7 @@ require 'rails_helper'
require 'mastodon/cli/main'
describe Mastodon::CLI::Main do
describe '.exit_on_failure?' do
it 'returns true' do
expect(described_class.exit_on_failure?).to be true
end
end
it_behaves_like 'CLI Command'
describe 'version' do
it 'returns the Mastodon version' do

View file

@ -6,11 +6,7 @@ require 'mastodon/cli/maintenance'
describe Mastodon::CLI::Maintenance do
let(:cli) { described_class.new }
describe '.exit_on_failure?' do
it 'returns true' do
expect(described_class.exit_on_failure?).to be true
end
end
it_behaves_like 'CLI Command'
describe '#fix_duplicates' do
context 'when the database version is too old' do

View file

@ -6,11 +6,7 @@ require 'mastodon/cli/media'
describe Mastodon::CLI::Media do
let(:cli) { described_class.new }
describe '.exit_on_failure?' do
it 'returns true' do
expect(described_class.exit_on_failure?).to be true
end
end
it_behaves_like 'CLI Command'
describe '#remove' do
context 'with --prune-profiles and --remove-headers' do
@ -78,4 +74,89 @@ describe Mastodon::CLI::Media do
end
end
end
describe '#usage' do
context 'without options' do
let(:options) { {} }
it 'reports about storage size' do
expect { cli.invoke(:usage, [], options) }.to output(
a_string_including('0 Bytes')
).to_stdout
end
end
end
describe '#refresh' do
context 'without any options' do
let(:options) { {} }
it 'warns about usage and exits' do
expect { cli.invoke(:refresh, [], options) }.to output(
a_string_including('Specify the source')
).to_stdout.and raise_error(SystemExit)
end
end
context 'with --status option' do
before do
media_attachment.update(file_file_name: nil)
end
let(:media_attachment) { Fabricate(:media_attachment, status: status, remote_url: 'https://host.example/asset.jpg') }
let(:options) { { status: status.id } }
let(:status) { Fabricate(:status) }
it 'redownloads the attachment file' do
expect { cli.invoke(:refresh, [], options) }.to output(
a_string_including('Downloaded 1 media')
).to_stdout
end
end
context 'with --account option' do
context 'when the account does not exist' do
let(:options) { { account: 'not-real-user@example.host' } }
it 'warns about usage and exits' do
expect { cli.invoke(:refresh, [], options) }.to output(
a_string_including('No such account')
).to_stdout.and raise_error(SystemExit)
end
end
context 'when the account exists' do
before do
media_attachment.update(file_file_name: nil)
end
let(:media_attachment) { Fabricate(:media_attachment, account: account) }
let(:options) { { account: account.acct } }
let(:account) { Fabricate(:account) }
it 'redownloads the attachment file' do
expect { cli.invoke(:refresh, [], options) }.to output(
a_string_including('Downloaded 1 media')
).to_stdout
end
end
end
context 'with --domain option' do
before do
media_attachment.update(file_file_name: nil)
end
let(:domain) { 'example.host' }
let(:media_attachment) { Fabricate(:media_attachment, account: account) }
let(:options) { { domain: domain } }
let(:account) { Fabricate(:account, domain: domain) }
it 'redownloads the attachment file' do
expect { cli.invoke(:refresh, [], options) }.to output(
a_string_including('Downloaded 1 media')
).to_stdout
end
end
end
end

View file

@ -6,11 +6,7 @@ require 'mastodon/cli/preview_cards'
describe Mastodon::CLI::PreviewCards do
let(:cli) { described_class.new }
describe '.exit_on_failure?' do
it 'returns true' do
expect(described_class.exit_on_failure?).to be true
end
end
it_behaves_like 'CLI Command'
describe '#remove' do
context 'with relevant preview cards' do

View file

@ -4,9 +4,5 @@ require 'rails_helper'
require 'mastodon/cli/search'
describe Mastodon::CLI::Search do
describe '.exit_on_failure?' do
it 'returns true' do
expect(described_class.exit_on_failure?).to be true
end
end
it_behaves_like 'CLI Command'
end

View file

@ -4,11 +4,7 @@ require 'rails_helper'
require 'mastodon/cli/settings'
describe Mastodon::CLI::Settings do
describe '.exit_on_failure?' do
it 'returns true' do
expect(described_class.exit_on_failure?).to be true
end
end
it_behaves_like 'CLI Command'
describe 'subcommand "registrations"' do
let(:cli) { Mastodon::CLI::Registrations.new }

View file

@ -6,11 +6,7 @@ require 'mastodon/cli/statuses'
describe Mastodon::CLI::Statuses do
let(:cli) { described_class.new }
describe '.exit_on_failure?' do
it 'returns true' do
expect(described_class.exit_on_failure?).to be true
end
end
it_behaves_like 'CLI Command'
describe '#remove', use_transactional_tests: false do
context 'with small batch size' do

View file

@ -4,9 +4,5 @@ require 'rails_helper'
require 'mastodon/cli/upgrade'
describe Mastodon::CLI::Upgrade do
describe '.exit_on_failure?' do
it 'returns true' do
expect(described_class.exit_on_failure?).to be true
end
end
it_behaves_like 'CLI Command'
end