Merge remote-tracking branch 'parent/main' into upstream-20231206
This commit is contained in:
commit
0199608b87
61 changed files with 781 additions and 162 deletions
|
@ -4,5 +4,22 @@ require 'rails_helper'
|
|||
require 'mastodon/cli/domains'
|
||||
|
||||
describe Mastodon::CLI::Domains do
|
||||
let(:cli) { described_class.new }
|
||||
|
||||
it_behaves_like 'CLI Command'
|
||||
|
||||
describe '#purge' do
|
||||
context 'with accounts from the domain' do
|
||||
let(:options) { {} }
|
||||
let(:domain) { 'host.example' }
|
||||
let!(:account) { Fabricate(:account, domain: domain) }
|
||||
|
||||
it 'removes the account' do
|
||||
expect { cli.invoke(:purge, [domain], options) }.to output(
|
||||
a_string_including('Removed 1 accounts')
|
||||
).to_stdout
|
||||
expect { account.reload }.to raise_error(ActiveRecord::RecordNotFound)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -4,5 +4,98 @@ require 'rails_helper'
|
|||
require 'mastodon/cli/email_domain_blocks'
|
||||
|
||||
describe Mastodon::CLI::EmailDomainBlocks do
|
||||
let(:cli) { described_class.new }
|
||||
|
||||
it_behaves_like 'CLI Command'
|
||||
|
||||
describe '#list' do
|
||||
context 'with email domain block records' do
|
||||
let!(:parent_block) { Fabricate(:email_domain_block) }
|
||||
let!(:child_block) { Fabricate(:email_domain_block, parent: parent_block) }
|
||||
let(:options) { {} }
|
||||
|
||||
it 'lists the blocks' do
|
||||
expect { cli.invoke(:list, [], options) }.to output(
|
||||
a_string_including(parent_block.domain)
|
||||
.and(a_string_including(child_block.domain))
|
||||
).to_stdout
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#add' do
|
||||
context 'without any options' do
|
||||
let(:options) { {} }
|
||||
|
||||
it 'warns about usage and exits' do
|
||||
expect { cli.invoke(:add, [], options) }.to output(
|
||||
a_string_including('No domain(s) given')
|
||||
).to_stdout.and raise_error(SystemExit)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when blocks exist' do
|
||||
let(:options) { {} }
|
||||
let(:domain) { 'host.example' }
|
||||
|
||||
before { Fabricate(:email_domain_block, domain: domain) }
|
||||
|
||||
it 'does not add a new block' do
|
||||
expect { cli.invoke(:add, [domain], options) }.to output(
|
||||
a_string_including('is already blocked')
|
||||
).to_stdout
|
||||
.and(not_change(EmailDomainBlock, :count))
|
||||
end
|
||||
end
|
||||
|
||||
context 'when no blocks exist' do
|
||||
let(:options) { {} }
|
||||
let(:domain) { 'host.example' }
|
||||
|
||||
it 'adds a new block' do
|
||||
expect { cli.invoke(:add, [domain], options) }.to output(
|
||||
a_string_including('Added 1')
|
||||
).to_stdout
|
||||
.and(change(EmailDomainBlock, :count).by(1))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#remove' do
|
||||
context 'without any options' do
|
||||
let(:options) { {} }
|
||||
|
||||
it 'warns about usage and exits' do
|
||||
expect { cli.invoke(:remove, [], options) }.to output(
|
||||
a_string_including('No domain(s) given')
|
||||
).to_stdout.and raise_error(SystemExit)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when blocks exist' do
|
||||
let(:options) { {} }
|
||||
let(:domain) { 'host.example' }
|
||||
|
||||
before { Fabricate(:email_domain_block, domain: domain) }
|
||||
|
||||
it 'removes the block' do
|
||||
expect { cli.invoke(:remove, [domain], options) }.to output(
|
||||
a_string_including('Removed 1')
|
||||
).to_stdout
|
||||
.and(change(EmailDomainBlock, :count).by(-1))
|
||||
end
|
||||
end
|
||||
|
||||
context 'when no blocks exist' do
|
||||
let(:options) { {} }
|
||||
let(:domain) { 'host.example' }
|
||||
|
||||
it 'does not remove a block' do
|
||||
expect { cli.invoke(:remove, [domain], options) }.to output(
|
||||
a_string_including('is not yet blocked')
|
||||
).to_stdout
|
||||
.and(not_change(EmailDomainBlock, :count))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -4,5 +4,24 @@ require 'rails_helper'
|
|||
require 'mastodon/cli/upgrade'
|
||||
|
||||
describe Mastodon::CLI::Upgrade do
|
||||
let(:cli) { described_class.new }
|
||||
|
||||
it_behaves_like 'CLI Command'
|
||||
|
||||
describe '#storage_schema' do
|
||||
context 'with records that dont need upgrading' do
|
||||
let(:options) { {} }
|
||||
|
||||
before do
|
||||
Fabricate(:account)
|
||||
Fabricate(:media_attachment)
|
||||
end
|
||||
|
||||
it 'does not upgrade storage for the attachments' do
|
||||
expect { cli.invoke(:storage_schema, [], options) }.to output(
|
||||
a_string_including('Upgraded storage schema of 0 records')
|
||||
).to_stdout
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue