0
0
Fork 0

Convert "CSV export" settings controller specs to request specs (#31601)

This commit is contained in:
Matt Jankowski 2024-08-27 04:12:39 -04:00 committed by GitHub
parent 38a3466741
commit a7f8417795
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 252 additions and 122 deletions

View file

@ -0,0 +1,42 @@
# frozen_string_literal: true
require 'rails_helper'
describe 'Settings / Exports / Blocked Accounts' do
describe 'GET /settings/exports/blocks' do
context 'with a signed in user who has blocked accounts' do
let(:user) { Fabricate :user }
before do
Fabricate(
:block,
account: user.account,
target_account: Fabricate(:account, username: 'username', domain: 'domain')
)
sign_in user
end
it 'returns a CSV with the blocking accounts' do
get '/settings/exports/blocks.csv'
expect(response)
.to have_http_status(200)
expect(response.content_type)
.to eq('text/csv')
expect(response.body)
.to eq(<<~CSV)
username@domain
CSV
end
end
describe 'when signed out' do
it 'returns unauthorized' do
get '/settings/exports/blocks.csv'
expect(response)
.to have_http_status(401)
end
end
end
end

View file

@ -0,0 +1,39 @@
# frozen_string_literal: true
require 'rails_helper'
describe 'Settings / Exports / Blocked Domains' do
describe 'GET /settings/exports/domain_blocks' do
context 'with a signed in user who has blocked domains' do
let(:account) { Fabricate :account, domain: 'example.com' }
let(:user) { Fabricate :user, account: account }
before do
Fabricate(:account_domain_block, domain: 'example.com', account: account)
sign_in user
end
it 'returns a CSV with the domains' do
get '/settings/exports/domain_blocks.csv'
expect(response)
.to have_http_status(200)
expect(response.content_type)
.to eq('text/csv')
expect(response.body)
.to eq(<<~CSV)
example.com
CSV
end
end
describe 'when signed out' do
it 'returns unauthorized' do
get '/settings/exports/domain_blocks.csv'
expect(response)
.to have_http_status(401)
end
end
end
end

View file

@ -0,0 +1,44 @@
# frozen_string_literal: true
require 'rails_helper'
describe 'Settings / Exports / Bookmarks' do
describe 'GET /settings/exports/bookmarks' do
context 'with a signed in user who has bookmarks' do
let(:account) { Fabricate(:account, domain: 'foo.bar') }
let(:status) { Fabricate(:status, account: account, uri: 'https://foo.bar/statuses/1312') }
let(:user) { Fabricate(:user) }
before do
Fabricate(
:bookmark,
account: user.account,
status: status
)
sign_in user
end
it 'returns a CSV with the bookmarked statuses' do
get '/settings/exports/bookmarks.csv'
expect(response)
.to have_http_status(200)
expect(response.content_type)
.to eq('text/csv')
expect(response.body)
.to eq(<<~CSV)
https://foo.bar/statuses/1312
CSV
end
end
describe 'when signed out' do
it 'returns unauthorized' do
get '/settings/exports/bookmarks.csv'
expect(response)
.to have_http_status(401)
end
end
end
end

View file

@ -0,0 +1,44 @@
# frozen_string_literal: true
require 'rails_helper'
describe 'Settings / Exports / Following Accounts' do
describe 'GET /settings/exports/follows' do
context 'with a signed in user who is following accounts' do
let(:user) { Fabricate :user }
before do
Fabricate(
:follow,
account: user.account,
target_account: Fabricate(:account, username: 'username', domain: 'domain'),
languages: ['en']
)
sign_in user
end
it 'returns a CSV with the accounts' do
get '/settings/exports/follows.csv'
expect(response)
.to have_http_status(200)
expect(response.content_type)
.to eq('text/csv')
expect(response.body)
.to eq(<<~CSV)
Account address,Show boosts,Notify on new posts,Languages
username@domain,true,false,en
CSV
end
end
describe 'when signed out' do
it 'returns unauthorized' do
get '/settings/exports/follows.csv'
expect(response)
.to have_http_status(401)
end
end
end
end

View 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

View file

@ -0,0 +1,43 @@
# frozen_string_literal: true
require 'rails_helper'
describe 'Settings / Exports / Muted Accounts' do
describe 'GET /settings/exports/mutes' do
context 'with a signed in user who has muted accounts' do
let(:user) { Fabricate :user }
before do
Fabricate(
:mute,
account: user.account,
target_account: Fabricate(:account, username: 'username', domain: 'domain')
)
sign_in user
end
it 'returns a CSV with the muted accounts' do
get '/settings/exports/mutes.csv'
expect(response)
.to have_http_status(200)
expect(response.content_type)
.to eq('text/csv')
expect(response.body)
.to eq(<<~CSV)
Account address,Hide notifications
username@domain,true
CSV
end
end
describe 'when signed out' do
it 'returns unauthorized' do
get '/settings/exports/mutes.csv'
expect(response)
.to have_http_status(401)
end
end
end
end