lists_spec.rb 1.0 KB

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