From 9603198982fce7e064a4ec60ac36420173a91cd5 Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Mon, 4 Dec 2023 04:09:05 -0500 Subject: [PATCH] Add spec coverage for `CLI::Domains#purge` command (#28179) --- spec/lib/mastodon/cli/domains_spec.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/spec/lib/mastodon/cli/domains_spec.rb b/spec/lib/mastodon/cli/domains_spec.rb index 765b63e2a7..add754159c 100644 --- a/spec/lib/mastodon/cli/domains_spec.rb +++ b/spec/lib/mastodon/cli/domains_spec.rb @@ -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