You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

64 lines
1.9 KiB

  1. require 'rails_helper'
  2. describe Export do
  3. let(:account) { Fabricate(:account) }
  4. let(:target_accounts) do
  5. [ {}, { username: 'one', domain: 'local.host' } ].map(&method(:Fabricate).curry(2).call(:account))
  6. end
  7. describe 'to_csv' do
  8. it 'returns a csv of the blocked accounts' do
  9. target_accounts.each(&account.method(:block!))
  10. export = Export.new(account).to_blocked_accounts_csv
  11. results = export.strip.split
  12. expect(results.size).to eq 2
  13. expect(results.first).to eq 'one@local.host'
  14. end
  15. it 'returns a csv of the muted accounts' do
  16. target_accounts.each(&account.method(:mute!))
  17. export = Export.new(account).to_muted_accounts_csv
  18. results = export.strip.split
  19. expect(results.size).to eq 2
  20. expect(results.first).to eq 'one@local.host'
  21. end
  22. it 'returns a csv of the following accounts' do
  23. target_accounts.each(&account.method(:follow!))
  24. export = Export.new(account).to_following_accounts_csv
  25. results = export.strip.split
  26. expect(results.size).to eq 2
  27. expect(results.first).to eq 'one@local.host'
  28. end
  29. end
  30. describe 'total_storage' do
  31. it 'returns the total size of the media attachments' do
  32. media_attachment = Fabricate(:media_attachment, account: account)
  33. expect(Export.new(account).total_storage).to eq media_attachment.file_file_size || 0
  34. end
  35. end
  36. describe 'total_follows' do
  37. it 'returns the total number of the followed accounts' do
  38. target_accounts.each(&account.method(:follow!))
  39. expect(Export.new(account.reload).total_follows).to eq 2
  40. end
  41. it 'returns the total number of the blocked accounts' do
  42. target_accounts.each(&account.method(:block!))
  43. expect(Export.new(account.reload).total_blocks).to eq 2
  44. end
  45. it 'returns the total number of the muted accounts' do
  46. target_accounts.each(&account.method(:mute!))
  47. expect(Export.new(account.reload).total_mutes).to eq 2
  48. end
  49. end
  50. end