mirror of https://github.com/mastodon/mastodon
Check both before/after state in `AccountDomainBlock` spec (#30640)
This commit is contained in:
parent
b124dff174
commit
62d070c438
|
@ -3,22 +3,30 @@
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe AccountDomainBlock do
|
RSpec.describe AccountDomainBlock do
|
||||||
|
let(:account) { Fabricate(:account) }
|
||||||
|
|
||||||
it 'removes blocking cache after creation' do
|
it 'removes blocking cache after creation' do
|
||||||
account = Fabricate(:account)
|
|
||||||
Rails.cache.write("exclude_domains_for:#{account.id}", 'a.domain.already.blocked')
|
Rails.cache.write("exclude_domains_for:#{account.id}", 'a.domain.already.blocked')
|
||||||
|
|
||||||
described_class.create!(account: account, domain: 'a.domain.blocked.later')
|
expect { block_domain_for_account('a.domain.blocked.later') }
|
||||||
|
.to change { account_has_exclude_domains_cache? }.to(false)
|
||||||
expect(Rails.cache.exist?("exclude_domains_for:#{account.id}")).to be false
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'removes blocking cache after destruction' do
|
it 'removes blocking cache after destruction' do
|
||||||
account = Fabricate(:account)
|
block = block_domain_for_account('domain')
|
||||||
block = described_class.create!(account: account, domain: 'domain')
|
|
||||||
Rails.cache.write("exclude_domains_for:#{account.id}", 'domain')
|
Rails.cache.write("exclude_domains_for:#{account.id}", 'domain')
|
||||||
|
|
||||||
block.destroy!
|
expect { block.destroy! }
|
||||||
|
.to change { account_has_exclude_domains_cache? }.to(false)
|
||||||
|
end
|
||||||
|
|
||||||
expect(Rails.cache.exist?("exclude_domains_for:#{account.id}")).to be false
|
private
|
||||||
|
|
||||||
|
def block_domain_for_account(domain)
|
||||||
|
Fabricate(:account_domain_block, account: account, domain: domain)
|
||||||
|
end
|
||||||
|
|
||||||
|
def account_has_exclude_domains_cache?
|
||||||
|
Rails.cache.exist?("exclude_domains_for:#{account.id}")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue