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.

66 lines
2.1 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("\n")
  19. expect(results.size).to eq 3
  20. expect(results.first).to eq 'Account address,Hide notifications'
  21. expect(results.second).to eq 'one@local.host,true'
  22. end
  23. it 'returns a csv of the following accounts' do
  24. target_accounts.each(&account.method(:follow!))
  25. export = Export.new(account).to_following_accounts_csv
  26. results = export.strip.split("\n")
  27. expect(results.size).to eq 3
  28. expect(results.first).to eq 'Account address,Show boosts'
  29. expect(results.second).to eq 'one@local.host,true'
  30. end
  31. end
  32. describe 'total_storage' do
  33. it 'returns the total size of the media attachments' do
  34. media_attachment = Fabricate(:media_attachment, account: account)
  35. expect(Export.new(account).total_storage).to eq media_attachment.file_file_size || 0
  36. end
  37. end
  38. describe 'total_follows' do
  39. it 'returns the total number of the followed accounts' do
  40. target_accounts.each(&account.method(:follow!))
  41. expect(Export.new(account.reload).total_follows).to eq 2
  42. end
  43. it 'returns the total number of the blocked accounts' do
  44. target_accounts.each(&account.method(:block!))
  45. expect(Export.new(account.reload).total_blocks).to eq 2
  46. end
  47. it 'returns the total number of the muted accounts' do
  48. target_accounts.each(&account.method(:mute!))
  49. expect(Export.new(account.reload).total_mutes).to eq 2
  50. end
  51. end
  52. end