闭社主体 forked from https://github.com/tootsuite/mastodon
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
866 B

  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. describe ApplicationController, type: :controller do
  4. controller do
  5. include ExportControllerConcern
  6. def index
  7. send_export_file
  8. end
  9. def export_data
  10. @export.account.username
  11. end
  12. end
  13. describe 'GET #index' do
  14. it 'returns a csv of the exported data when signed in' do
  15. user = Fabricate(:user)
  16. sign_in user
  17. get :index, format: :csv
  18. expect(response).to have_http_status(200)
  19. expect(response.content_type).to eq 'text/csv'
  20. expect(response.headers['Content-Disposition']).to eq 'attachment; filename="anonymous.csv"'
  21. expect(response.body).to eq user.account.username
  22. end
  23. it 'returns unauthorized when not signed in' do
  24. get :index, format: :csv
  25. expect(response).to have_http_status(:unauthorized)
  26. end
  27. end
  28. end