1
0

account_domain_block_spec.rb 918 B

1234567891011121314151617181920212223242526272829303132
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. RSpec.describe AccountDomainBlock do
  4. let(:account) { Fabricate(:account) }
  5. it 'removes blocking cache after creation' do
  6. Rails.cache.write("exclude_domains_for:#{account.id}", 'a.domain.already.blocked')
  7. expect { block_domain_for_account('a.domain.blocked.later') }
  8. .to change { account_has_exclude_domains_cache? }.to(false)
  9. end
  10. it 'removes blocking cache after destruction' do
  11. block = block_domain_for_account('domain')
  12. Rails.cache.write("exclude_domains_for:#{account.id}", 'domain')
  13. expect { block.destroy! }
  14. .to change { account_has_exclude_domains_cache? }.to(false)
  15. end
  16. private
  17. def block_domain_for_account(domain)
  18. Fabricate(:account_domain_block, account: account, domain: domain)
  19. end
  20. def account_has_exclude_domains_cache?
  21. Rails.cache.exist?("exclude_domains_for:#{account.id}")
  22. end
  23. end