2023-02-22 11:55:31 +11:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-04-12 06:00:43 +10:00
|
|
|
require 'rails_helper'
|
|
|
|
|
2024-09-04 15:12:25 +10:00
|
|
|
RSpec.describe Export do
|
2024-10-02 19:43:04 +10:00
|
|
|
subject { described_class.new(account) }
|
|
|
|
|
2017-06-19 19:30:27 +10:00
|
|
|
let(:account) { Fabricate(:account) }
|
|
|
|
let(:target_accounts) do
|
2024-10-02 19:43:04 +10:00
|
|
|
[
|
|
|
|
Fabricate(:account),
|
|
|
|
Fabricate(:account, username: 'one', domain: 'local.host'),
|
|
|
|
]
|
2017-06-19 19:30:27 +10:00
|
|
|
end
|
2017-04-13 23:29:30 +10:00
|
|
|
|
2024-10-02 19:43:04 +10:00
|
|
|
describe '#to_bookmarks_csv' do
|
|
|
|
before { Fabricate.times(2, :bookmark, account: account) }
|
2017-06-19 19:30:27 +10:00
|
|
|
|
2024-10-02 19:43:04 +10:00
|
|
|
let(:export) { CSV.parse(subject.to_bookmarks_csv) }
|
2017-04-13 23:29:30 +10:00
|
|
|
|
2024-10-02 19:43:04 +10:00
|
|
|
it 'returns a csv of bookmarks' do
|
|
|
|
expect(export)
|
|
|
|
.to contain_exactly(
|
|
|
|
include(/statuses/),
|
|
|
|
include(/statuses/)
|
|
|
|
)
|
2017-04-13 23:29:30 +10:00
|
|
|
end
|
2024-10-02 19:43:04 +10:00
|
|
|
end
|
2017-04-13 23:29:30 +10:00
|
|
|
|
2024-10-02 19:43:04 +10:00
|
|
|
describe '#to_blocked_accounts_csv' do
|
|
|
|
before { target_accounts.each { |target_account| account.block!(target_account) } }
|
|
|
|
|
|
|
|
let(:export) { CSV.parse(subject.to_blocked_accounts_csv) }
|
|
|
|
|
|
|
|
it 'returns a csv of the blocked accounts' do
|
|
|
|
expect(export)
|
|
|
|
.to contain_exactly(
|
|
|
|
include('one@local.host'),
|
|
|
|
include(be_present)
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
2017-06-19 19:30:27 +10:00
|
|
|
|
2024-10-02 19:43:04 +10:00
|
|
|
describe '#to_muted_accounts_csv' do
|
|
|
|
before { target_accounts.each { |target_account| account.mute!(target_account) } }
|
2017-04-13 23:29:30 +10:00
|
|
|
|
2024-10-02 19:43:04 +10:00
|
|
|
let(:export) { CSV.parse(subject.to_muted_accounts_csv) }
|
|
|
|
|
|
|
|
it 'returns a csv of the muted accounts' do
|
|
|
|
expect(export)
|
|
|
|
.to contain_exactly(
|
|
|
|
contain_exactly('Account address', 'Hide notifications'),
|
|
|
|
include('one@local.host', 'true'),
|
|
|
|
include(be_present)
|
|
|
|
)
|
2017-04-13 23:29:30 +10:00
|
|
|
end
|
2024-10-02 19:43:04 +10:00
|
|
|
end
|
|
|
|
|
|
|
|
describe '#to_following_accounts_csv' do
|
|
|
|
before { target_accounts.each { |target_account| account.follow!(target_account) } }
|
|
|
|
|
|
|
|
let(:export) { CSV.parse(subject.to_following_accounts_csv) }
|
2017-04-13 23:29:30 +10:00
|
|
|
|
|
|
|
it 'returns a csv of the following accounts' do
|
2024-10-02 19:43:04 +10:00
|
|
|
expect(export)
|
|
|
|
.to contain_exactly(
|
|
|
|
contain_exactly('Account address', 'Show boosts', 'Notify on new posts', 'Languages'),
|
|
|
|
include('one@local.host', 'true', 'false', be_blank),
|
|
|
|
include(be_present)
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#to_lists_csv' do
|
|
|
|
before do
|
|
|
|
target_accounts.each do |target_account|
|
|
|
|
account.follow!(target_account)
|
|
|
|
Fabricate(:list, account: account).accounts << target_account
|
|
|
|
end
|
|
|
|
end
|
2017-06-19 19:30:27 +10:00
|
|
|
|
2024-10-02 19:43:04 +10:00
|
|
|
let(:export) { CSV.parse(subject.to_lists_csv) }
|
2017-04-12 06:00:43 +10:00
|
|
|
|
2024-10-02 19:43:04 +10:00
|
|
|
it 'returns a csv of the lists' do
|
|
|
|
expect(export)
|
|
|
|
.to contain_exactly(
|
|
|
|
include('one@local.host'),
|
|
|
|
include(be_present)
|
|
|
|
)
|
2017-04-12 06:00:43 +10:00
|
|
|
end
|
|
|
|
end
|
2017-06-19 19:30:27 +10:00
|
|
|
|
2024-10-02 19:43:04 +10:00
|
|
|
describe '#to_blocked_domains_csv' do
|
|
|
|
before { Fabricate.times(2, :account_domain_block, account: account) }
|
|
|
|
|
|
|
|
let(:export) { CSV.parse(subject.to_blocked_domains_csv) }
|
|
|
|
|
|
|
|
it 'returns a csv of the blocked domains' do
|
|
|
|
expect(export)
|
|
|
|
.to contain_exactly(
|
|
|
|
include(/example/),
|
|
|
|
include(/example/)
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#total_storage' do
|
2017-06-19 19:30:27 +10:00
|
|
|
it 'returns the total size of the media attachments' do
|
|
|
|
media_attachment = Fabricate(:media_attachment, account: account)
|
2024-10-02 19:43:04 +10:00
|
|
|
expect(subject.total_storage).to eq media_attachment.file_file_size || 0
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#total_statuses' do
|
|
|
|
before { Fabricate.times(2, :status, account: account) }
|
|
|
|
|
|
|
|
it 'returns the total number of statuses' do
|
|
|
|
expect(subject.total_statuses).to eq(2)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#total_bookmarks' do
|
|
|
|
before { Fabricate.times(2, :bookmark, account: account) }
|
|
|
|
|
|
|
|
it 'returns the total number of bookmarks' do
|
|
|
|
expect(subject.total_bookmarks).to eq(2)
|
2017-06-19 19:30:27 +10:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2024-10-02 19:43:04 +10:00
|
|
|
describe '#total_follows' do
|
|
|
|
before { target_accounts.each { |target_account| account.follow!(target_account) } }
|
|
|
|
|
2017-06-19 19:30:27 +10:00
|
|
|
it 'returns the total number of the followed accounts' do
|
2024-10-02 19:43:04 +10:00
|
|
|
expect(subject.total_follows).to eq(2)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#total_lists' do
|
|
|
|
before { Fabricate.times(2, :list, account: account) }
|
|
|
|
|
|
|
|
it 'returns the total number of lists' do
|
|
|
|
expect(subject.total_lists).to eq(2)
|
2017-06-19 19:30:27 +10:00
|
|
|
end
|
2024-10-02 19:43:04 +10:00
|
|
|
end
|
|
|
|
|
|
|
|
describe '#total_followers' do
|
|
|
|
before { target_accounts.each { |target_account| target_account.follow!(account) } }
|
|
|
|
|
|
|
|
it 'returns the total number of the follower accounts' do
|
|
|
|
expect(subject.total_followers).to eq(2)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#total_blocks' do
|
|
|
|
before { target_accounts.each { |target_account| account.block!(target_account) } }
|
2017-06-19 19:30:27 +10:00
|
|
|
|
|
|
|
it 'returns the total number of the blocked accounts' do
|
2024-10-02 19:43:04 +10:00
|
|
|
expect(subject.total_blocks).to eq(2)
|
2017-06-19 19:30:27 +10:00
|
|
|
end
|
2024-10-02 19:43:04 +10:00
|
|
|
end
|
|
|
|
|
|
|
|
describe '#total_mutes' do
|
|
|
|
before { target_accounts.each { |target_account| account.mute!(target_account) } }
|
2017-06-19 19:30:27 +10:00
|
|
|
|
|
|
|
it 'returns the total number of the muted accounts' do
|
2024-10-02 19:43:04 +10:00
|
|
|
expect(subject.total_mutes).to eq(2)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#total_domain_blocks' do
|
|
|
|
before { Fabricate.times(2, :account_domain_block, account: account) }
|
|
|
|
|
|
|
|
it 'returns the total number of account domain blocks' do
|
|
|
|
expect(subject.total_domain_blocks).to eq(2)
|
2017-06-19 19:30:27 +10:00
|
|
|
end
|
|
|
|
end
|
2017-04-12 06:00:43 +10:00
|
|
|
end
|