Skip to content
Snippets Groups Projects
Commit d55f2072 authored by Akihiko Odaki (@fn_aki@pawoo.net)'s avatar Akihiko Odaki (@fn_aki@pawoo.net) Committed by Eugen Rochko
Browse files

Cover Export more (#3840)

parent cf6fe4f8
No related branches found
No related tags found
No related merge requests found
Fabricator(:media_attachment) do Fabricator(:media_attachment) do
account account
file { [attachment_fixture(['attachment.gif', 'attachment.jpg', 'attachment.webm'].sample), nil].sample }
end end
require 'rails_helper' require 'rails_helper'
describe Export do describe Export do
describe 'to_csv' do let(:account) { Fabricate(:account) }
before do let(:target_accounts) do
one = Account.new(username: 'one', domain: 'local.host') [ {}, { username: 'one', domain: 'local.host' } ].map(&method(:Fabricate).curry(2).call(:account))
two = Account.new(username: 'two', domain: 'local.host') end
accounts = [one, two]
@account = double(blocking: accounts, muting: accounts, following: accounts)
end
describe 'to_csv' do
it 'returns a csv of the blocked accounts' do it 'returns a csv of the blocked accounts' do
export = Export.new(@account).to_blocked_accounts_csv target_accounts.each(&account.method(:block!))
export = Export.new(account).to_blocked_accounts_csv
results = export.strip.split results = export.strip.split
expect(results.size).to eq 2 expect(results.size).to eq 2
...@@ -19,7 +18,9 @@ describe Export do ...@@ -19,7 +18,9 @@ describe Export do
end end
it 'returns a csv of the muted accounts' do it 'returns a csv of the muted accounts' do
export = Export.new(@account).to_muted_accounts_csv target_accounts.each(&account.method(:mute!))
export = Export.new(account).to_muted_accounts_csv
results = export.strip.split results = export.strip.split
expect(results.size).to eq 2 expect(results.size).to eq 2
...@@ -27,11 +28,37 @@ describe Export do ...@@ -27,11 +28,37 @@ describe Export do
end end
it 'returns a csv of the following accounts' do it 'returns a csv of the following accounts' do
export = Export.new(@account).to_following_accounts_csv target_accounts.each(&account.method(:follow!))
export = Export.new(account).to_following_accounts_csv
results = export.strip.split results = export.strip.split
expect(results.size).to eq 2 expect(results.size).to eq 2
expect(results.first).to eq 'one@local.host' expect(results.first).to eq 'one@local.host'
end end
end end
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!))
expect(Export.new(account).total_follows).to eq 2
end
it 'returns the total number of the blocked accounts' do
target_accounts.each(&account.method(:block!))
expect(Export.new(account).total_blocks).to eq 2
end
it 'returns the total number of the muted accounts' do
target_accounts.each(&account.method(:mute!))
expect(Export.new(account).total_mutes).to eq 2
end
end
end end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment