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.
36 lines
878 B
36 lines
878 B
8 years ago
|
# frozen_string_literal: true
|
||
|
|
||
|
require 'rails_helper'
|
||
|
|
||
12 months ago
|
describe Settings::ExportControllerConcern do
|
||
1 year ago
|
controller(ApplicationController) do
|
||
12 months ago
|
include Settings::ExportControllerConcern
|
||
4 years ago
|
|
||
8 years ago
|
def index
|
||
|
send_export_file
|
||
|
end
|
||
6 years ago
|
|
||
8 years ago
|
def export_data
|
||
1 year ago
|
'body data value'
|
||
8 years ago
|
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
|
||
|
|
||
7 years ago
|
expect(response).to have_http_status(200)
|
||
4 years ago
|
expect(response.media_type).to eq 'text/csv'
|
||
|
expect(response.headers['Content-Disposition']).to start_with 'attachment; filename="anonymous.csv"'
|
||
1 year ago
|
expect(response.body).to eq 'body data value'
|
||
8 years ago
|
end
|
||
|
|
||
|
it 'returns unauthorized when not signed in' do
|
||
|
get :index, format: :csv
|
||
2 years ago
|
expect(response).to have_http_status(401)
|
||
8 years ago
|
end
|
||
|
end
|
||
|
end
|