bookmarks_spec.rb 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. RSpec.describe 'Settings / Exports / Bookmarks' do
  4. describe 'GET /settings/exports/bookmarks' do
  5. context 'with a signed in user who has bookmarks' do
  6. let(:account) { Fabricate(:account, domain: 'foo.bar') }
  7. let(:status) { Fabricate(:status, account: account, uri: 'https://foo.bar/statuses/1312') }
  8. let(:user) { Fabricate(:user) }
  9. before do
  10. Fabricate(
  11. :bookmark,
  12. account: user.account,
  13. status: status
  14. )
  15. sign_in user
  16. end
  17. it 'returns a CSV with the bookmarked statuses' do
  18. get '/settings/exports/bookmarks.csv'
  19. expect(response)
  20. .to have_http_status(200)
  21. expect(response.content_type)
  22. .to eq('text/csv')
  23. expect(response.body)
  24. .to eq(<<~CSV)
  25. https://foo.bar/statuses/1312
  26. CSV
  27. end
  28. end
  29. describe 'when signed out' do
  30. it 'returns unauthorized' do
  31. get '/settings/exports/bookmarks.csv'
  32. expect(response)
  33. .to have_http_status(401)
  34. end
  35. end
  36. end
  37. end