diff options
author | Akihiko Odaki (@fn_aki@pawoo.net) <akihiko.odaki.4i@stu.hosei.ac.jp> | 2017-06-19 18:30:27 +0900 |
---|---|---|
committer | Eugen Rochko <eugen@zeonfederated.com> | 2017-06-19 11:30:27 +0200 |
commit | d55f207274648369cba30ff001aa3e354fa30dca (patch) | |
tree | bcc6d01efe36e34025e2503092e99328004fe3e4 | |
parent | cf6fe4f8cbafeb2f4e3a92bac4f3909cfc327edf (diff) |
Cover Export more (#3840)
-rw-r--r-- | spec/fabricators/media_attachment_fabricator.rb | 1 | ||||
-rw-r--r-- | spec/models/export_spec.rb | 49 |
2 files changed, 39 insertions, 11 deletions
diff --git a/spec/fabricators/media_attachment_fabricator.rb b/spec/fabricators/media_attachment_fabricator.rb index dc91d708f..c5dfe12e5 100644 --- a/spec/fabricators/media_attachment_fabricator.rb +++ b/spec/fabricators/media_attachment_fabricator.rb @@ -1,3 +1,4 @@ Fabricator(:media_attachment) do account + file { [attachment_fixture(['attachment.gif', 'attachment.jpg', 'attachment.webm'].sample), nil].sample } end diff --git a/spec/models/export_spec.rb b/spec/models/export_spec.rb index 3ee042fb6..6daa46145 100644 --- a/spec/models/export_spec.rb +++ b/spec/models/export_spec.rb @@ -1,17 +1,16 @@ require 'rails_helper' describe Export do - describe 'to_csv' do - before do - one = Account.new(username: 'one', domain: 'local.host') - two = Account.new(username: 'two', domain: 'local.host') - accounts = [one, two] - - @account = double(blocking: accounts, muting: accounts, following: accounts) - end + let(:account) { Fabricate(:account) } + let(:target_accounts) do + [ {}, { username: 'one', domain: 'local.host' } ].map(&method(:Fabricate).curry(2).call(:account)) + end + describe 'to_csv' 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 expect(results.size).to eq 2 @@ -19,7 +18,9 @@ describe Export do end 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 expect(results.size).to eq 2 @@ -27,11 +28,37 @@ describe Export do end 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 expect(results.size).to eq 2 expect(results.first).to eq 'one@local.host' 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 |