1
0
mirror of https://github.com/funamitech/mastodon synced 2024-11-27 06:18:53 +09:00

Fix error in CLI EmailDomainBlocks when supplying --with-dns-records (#32863)

This commit is contained in:
Matt Jankowski 2024-11-13 03:39:58 -05:00 committed by GitHub
parent 2bd56f726a
commit a6d829e86f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 17 additions and 1 deletions

View File

@ -48,7 +48,7 @@ module Mastodon::CLI
if options[:with_dns_records] if options[:with_dns_records]
Resolv::DNS.open do |dns| Resolv::DNS.open do |dns|
dns.timeouts = 5 dns.timeouts = 5
other_domains = dns.getresources(@email_domain_block.domain, Resolv::DNS::Resource::IN::MX).to_a other_domains = dns.getresources(domain, Resolv::DNS::Resource::IN::MX).to_a.map { |e| e.exchange.to_s }.compact_blank
end end
end end

View File

@ -63,6 +63,22 @@ RSpec.describe Mastodon::CLI::EmailDomainBlocks do
.and(change(EmailDomainBlock, :count).by(1)) .and(change(EmailDomainBlock, :count).by(1))
end end
end end
context 'with --with-dns-records true' do
let(:domain) { 'host.example' }
let(:arguments) { [domain] }
let(:options) { { with_dns_records: true } }
before do
configure_mx(domain: domain, exchange: 'other.host')
end
it 'adds a new block for parent and children' do
expect { subject }
.to output_results('Added 2')
.and(change(EmailDomainBlock, :count).by(2))
end
end
end end
describe '#remove' do describe '#remove' do