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
870 B
34 lines
870 B
8 years ago
|
# frozen_string_literal: true
|
||
|
|
||
|
require 'rails_helper'
|
||
|
|
||
8 years ago
|
describe ApplicationController, type: :controller do
|
||
8 years ago
|
controller do
|
||
8 years ago
|
include ExportControllerConcern
|
||
|
def index
|
||
|
send_export_file
|
||
|
end
|
||
8 years ago
|
def export_data
|
||
|
@export.account.username
|
||
|
end
|
||
|
end
|
||
|
|
||
|
describe 'GET #index' do
|
||
|
it 'returns a csv of the exported data when signed in' do
|
||
|
user = Fabricate(:user)
|
||
|
sign_in user
|
||
|
get :index, format: :csv
|
||
|
|
||
|
expect(response).to have_http_status(:success)
|
||
|
expect(response.content_type).to eq 'text/csv'
|
||
8 years ago
|
expect(response.headers['Content-Disposition']).to eq 'attachment; filename="anonymous.csv"'
|
||
8 years ago
|
expect(response.body).to eq user.account.username
|
||
|
end
|
||
|
|
||
|
it 'returns unauthorized when not signed in' do
|
||
|
get :index, format: :csv
|
||
|
expect(response).to have_http_status(:unauthorized)
|
||
|
end
|
||
|
end
|
||
|
end
|