Files
mastodon/spec/models/export_spec.rb
jcoffey-dev 319ed76dbd
Crowdin / Upload translations / upload-translations (push) Skipped
Historical data migration test / test (14-alpine) (push) Canceled after 0s
Historical data migration test / test (15-alpine) (push) Canceled after 0s
Historical data migration test / test (16-alpine) (push) Canceled after 0s
Historical data migration test / test (17-alpine) (push) Canceled after 0s
Bundler Audit / security (push) Canceled after 0s
Haml Linting / lint (push) Canceled after 0s
JavaScript Linting / lint (push) Canceled after 0s
Ruby Linting / lint (push) Canceled after 0s
JavaScript Testing / test (push) Canceled after 0s
Ruby Testing / build (production) (push) Canceled after 0s
Ruby Testing / test (.ruby-version) (push) Canceled after 0s
Ruby Testing / test (3.3) (push) Canceled after 0s
Ruby Testing / test (3.4) (push) Canceled after 0s
Ruby Testing / End to End testing (.ruby-version) (push) Canceled after 0s
Ruby Testing / End to End testing (3.3) (push) Canceled after 0s
Ruby Testing / End to End testing (3.4) (push) Canceled after 0s
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:7.17.29) (push) Canceled after 0s
Check i18n / check-i18n (push) Canceled after 0s
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (javascript) (push) Canceled after 0s
CodeQL / Analyze (ruby) (push) Canceled after 0s
Ruby Testing / Elastic Search integration testing (.ruby-version, opensearchproject/opensearch:2) (push) Canceled after 0s
Ruby Testing / Elastic Search integration testing (3.3, docker.elastic.co/elasticsearch/elasticsearch:7.17.29) (push) Canceled after 0s
Ruby Testing / Elastic Search integration testing (3.4, docker.elastic.co/elasticsearch/elasticsearch:7.17.29) (push) Canceled after 0s
Check formatting / lint (push) Canceled after 0s
CSS Linting / lint (push) Canceled after 0s
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:8.19.2) (push) Canceled after 0s
Chromatic / Check for relevant changes (push) Canceled after 0s
Chromatic / Run Chromatic (push) Canceled after 0s
Import Mastodon v4.7.3
Snapshot of upstream tag v4.7.3 (commit 8ff11c2bb7b9f0714e947b10fa3629c6542c7121) from
https://github.com/mastodon/mastodon, unmodified.
2026-10-05 22:03:13 -07:00

112 lines
3.0 KiB
Ruby

# frozen_string_literal: true
require 'rails_helper'
RSpec.describe Export do
subject { described_class.new(account) }
let(:account) { Fabricate(:account) }
let(:target_accounts) do
[
Fabricate(:account),
Fabricate(:account, username: 'one', domain: 'local.host'),
]
end
describe '#to_bookmarks_csv' do
let!(:bookmark) { Fabricate(:bookmark, account: account) }
let(:export) { CSV.parse(subject.to_bookmarks_csv) }
let!(:second_bookmark) { Fabricate(:bookmark, account: account) }
let!(:bookmark_of_soft_deleted) { Fabricate(:bookmark, account: account) }
before do
bookmark_of_soft_deleted.status.discard
end
it 'returns a csv of bookmarks' do
expect(export)
.to contain_exactly(
[ActivityPub::TagManager.instance.uri_for(bookmark.status)],
[ActivityPub::TagManager.instance.uri_for(second_bookmark.status)]
)
end
end
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('[email protected]'),
include(be_present)
)
end
end
describe '#to_muted_accounts_csv' do
before { target_accounts.each { |target_account| account.mute!(target_account) } }
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('[email protected]', 'true'),
include(be_present)
)
end
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) }
it 'returns a csv of the following accounts' do
expect(export)
.to contain_exactly(
contain_exactly('Account address', 'Show boosts', 'Notify on new posts', 'Languages'),
include('[email protected]', '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
let(:export) { CSV.parse(subject.to_lists_csv) }
it 'returns a csv of the lists' do
expect(export)
.to contain_exactly(
include('[email protected]'),
include(be_present)
)
end
end
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
end