2017-04-11 13:00:43 -07:00
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
describe Export do
|
2017-06-19 02:30:27 -07:00
|
|
|
let(:account) { Fabricate(:account) }
|
|
|
|
let(:target_accounts) do
|
|
|
|
[ {}, { username: 'one', domain: 'local.host' } ].map(&method(:Fabricate).curry(2).call(:account))
|
|
|
|
end
|
2017-04-13 06:29:30 -07:00
|
|
|
|
2017-06-19 02:30:27 -07:00
|
|
|
describe 'to_csv' do
|
2017-04-13 06:29:30 -07:00
|
|
|
it 'returns a csv of the blocked accounts' do
|
2017-06-19 02:30:27 -07:00
|
|
|
target_accounts.each(&account.method(:block!))
|
|
|
|
|
|
|
|
export = Export.new(account).to_blocked_accounts_csv
|
2017-04-13 06:29:30 -07:00
|
|
|
results = export.strip.split
|
|
|
|
|
|
|
|
expect(results.size).to eq 2
|
|
|
|
expect(results.first).to eq 'one@local.host'
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns a csv of the muted accounts' do
|
2017-06-19 02:30:27 -07:00
|
|
|
target_accounts.each(&account.method(:mute!))
|
|
|
|
|
|
|
|
export = Export.new(account).to_muted_accounts_csv
|
2017-04-13 06:29:30 -07:00
|
|
|
results = export.strip.split
|
|
|
|
|
|
|
|
expect(results.size).to eq 2
|
|
|
|
expect(results.first).to eq 'one@local.host'
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns a csv of the following accounts' do
|
2017-06-19 02:30:27 -07:00
|
|
|
target_accounts.each(&account.method(:follow!))
|
|
|
|
|
|
|
|
export = Export.new(account).to_following_accounts_csv
|
2017-04-11 13:00:43 -07:00
|
|
|
results = export.strip.split
|
|
|
|
|
|
|
|
expect(results.size).to eq 2
|
|
|
|
expect(results.first).to eq 'one@local.host'
|
|
|
|
end
|
|
|
|
end
|
2017-06-19 02:30:27 -07:00
|
|
|
|
|
|
|
describe 'total_storage' do
|
|
|
|
it 'returns the total size of the media attachments' do
|
|
|
|
media_attachment = Fabricate(:media_attachment, account: account)
|
|
|
|
expect(Export.new(account).total_storage).to eq media_attachment.file_file_size || 0
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'total_follows' do
|
|
|
|
it 'returns the total number of the followed accounts' do
|
|
|
|
target_accounts.each(&account.method(:follow!))
|
2018-08-14 12:56:17 -07:00
|
|
|
expect(Export.new(account.reload).total_follows).to eq 2
|
2017-06-19 02:30:27 -07:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns the total number of the blocked accounts' do
|
|
|
|
target_accounts.each(&account.method(:block!))
|
2018-08-14 12:56:17 -07:00
|
|
|
expect(Export.new(account.reload).total_blocks).to eq 2
|
2017-06-19 02:30:27 -07:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns the total number of the muted accounts' do
|
|
|
|
target_accounts.each(&account.method(:mute!))
|
2018-08-14 12:56:17 -07:00
|
|
|
expect(Export.new(account.reload).total_mutes).to eq 2
|
2017-06-19 02:30:27 -07:00
|
|
|
end
|
|
|
|
end
|
2017-04-11 13:00:43 -07:00
|
|
|
end
|