Convert "CSV export" settings controller specs to request specs (#31601)
This commit is contained in:
parent
38a3466741
commit
a7f8417795
12 changed files with 252 additions and 122 deletions
40
spec/requests/settings/exports/lists_spec.rb
Normal file
40
spec/requests/settings/exports/lists_spec.rb
Normal file
|
@ -0,0 +1,40 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'Settings / Exports / Lists' do
|
||||
describe 'GET /settings/exports/lists' do
|
||||
context 'with a signed in user who has lists' do
|
||||
let(:account) { Fabricate(:account, username: 'test', domain: 'example.com') }
|
||||
let(:list) { Fabricate :list, account: account, title: 'The List' }
|
||||
let(:user) { Fabricate(:user, account: account) }
|
||||
|
||||
before do
|
||||
Fabricate(:list_account, list: list, account: account)
|
||||
sign_in user
|
||||
end
|
||||
|
||||
it 'returns a CSV with the list' do
|
||||
get '/settings/exports/lists.csv'
|
||||
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to eq('text/csv')
|
||||
expect(response.body)
|
||||
.to eq(<<~CSV)
|
||||
The List,test@example.com
|
||||
CSV
|
||||
end
|
||||
end
|
||||
|
||||
describe 'when signed out' do
|
||||
it 'returns unauthorized' do
|
||||
get '/settings/exports/lists.csv'
|
||||
|
||||
expect(response)
|
||||
.to have_http_status(401)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue