blocked_domains_spec.rb 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. RSpec.describe 'Settings / Exports / Blocked Domains' do
  4. describe 'GET /settings/exports/domain_blocks' do
  5. context 'with a signed in user who has blocked domains' do
  6. let(:account) { Fabricate :account, domain: 'example.com' }
  7. let(:user) { Fabricate :user, account: account }
  8. before do
  9. Fabricate(:account_domain_block, domain: 'example.com', account: account)
  10. sign_in user
  11. end
  12. it 'returns a CSV with the domains' do
  13. get '/settings/exports/domain_blocks.csv'
  14. expect(response)
  15. .to have_http_status(200)
  16. expect(response.content_type)
  17. .to eq('text/csv')
  18. expect(response.body)
  19. .to eq(<<~CSV)
  20. example.com
  21. CSV
  22. end
  23. end
  24. describe 'when signed out' do
  25. it 'returns unauthorized' do
  26. get '/settings/exports/domain_blocks.csv'
  27. expect(response)
  28. .to have_http_status(401)
  29. end
  30. end
  31. end
  32. end