diff options
author | multiple creatures <dev@multiple-creature.party> | 2019-05-09 09:40:09 -0500 |
---|---|---|
committer | multiple creatures <dev@multiple-creature.party> | 2019-05-21 03:16:23 -0500 |
commit | e85b8af05183d1048adc4a39bc3d975af153463d (patch) | |
tree | 0cda58965ce9c8104cd65a6761678f2154bacd08 /spec/services/import_service_spec.rb | |
parent | 66886d4367b64d6860c55ab6f8a57a31ed9b59de (diff) |
Second round of Rspec fixes.
Diffstat (limited to 'spec/services/import_service_spec.rb')
-rw-r--r-- | spec/services/import_service_spec.rb | 41 |
1 files changed, 20 insertions, 21 deletions
diff --git a/spec/services/import_service_spec.rb b/spec/services/import_service_spec.rb index 5cf2dadf0..35a5dbc51 100644 --- a/spec/services/import_service_spec.rb +++ b/spec/services/import_service_spec.rb @@ -3,7 +3,11 @@ require 'rails_helper' RSpec.describe ImportService, type: :service do let!(:account) { Fabricate(:account, locked: false) } let!(:bob) { Fabricate(:account, username: 'bob', locked: false) } - let!(:eve) { Fabricate(:account, username: 'eve', domain: 'example.com', locked: false) } + let!(:foo) { Fabricate(:account, username: 'foo', domain: 'ap.example.com', inbox_url: 'https://ap.example.com/inbox', locked: false) } + + before do + stub_request(:post, "https://ap.example.com/inbox").to_return(:status => 200, :body => "", :headers => {}) + end context 'import old-style list of muted users' do subject { ImportService.new } @@ -53,7 +57,7 @@ RSpec.describe ImportService, type: :service do subject.call(import) expect(account.muting.count).to eq 2 expect(Mute.find_by(account: account, target_account: bob).hide_notifications).to be true - expect(Mute.find_by(account: account, target_account: eve).hide_notifications).to be false + expect(Mute.find_by(account: account, target_account: foo).hide_notifications).to be false end end @@ -65,7 +69,7 @@ RSpec.describe ImportService, type: :service do subject.call(import) expect(account.muting.count).to eq 2 expect(Mute.find_by(account: account, target_account: bob).hide_notifications).to be true - expect(Mute.find_by(account: account, target_account: eve).hide_notifications).to be false + expect(Mute.find_by(account: account, target_account: foo).hide_notifications).to be false end end @@ -77,7 +81,7 @@ RSpec.describe ImportService, type: :service do subject.call(import) expect(account.muting.count).to eq 2 expect(Mute.find_by(account: account, target_account: bob).hide_notifications).to be true - expect(Mute.find_by(account: account, target_account: eve).hide_notifications).to be false + expect(Mute.find_by(account: account, target_account: foo).hide_notifications).to be false end end end @@ -87,16 +91,13 @@ RSpec.describe ImportService, type: :service do let(:csv) { attachment_fixture('mute-imports.txt') } - before do - allow(NotificationWorker).to receive(:perform_async) - end - describe 'when no accounts are followed' do let(:import) { Import.create(account: account, type: 'following', data: csv) } it 'follows the listed accounts, including boosts' do subject.call(import) - expect(account.following.count).to eq 2 + expect(account.following.count).to eq 1 expect(Follow.find_by(account: account, target_account: bob).show_reblogs).to be true + expect(FollowRequest.find_by(account: account, target_account: foo)).to_not be_nil end end @@ -106,8 +107,9 @@ RSpec.describe ImportService, type: :service do it 'follows the listed accounts, including notifications' do account.follow!(bob, reblogs: false) subject.call(import) - expect(account.following.count).to eq 2 + expect(account.following.count).to eq 1 expect(Follow.find_by(account: account, target_account: bob).show_reblogs).to be true + expect(FollowRequest.find_by(account: account, target_account: foo)).to_not be_nil end end @@ -117,8 +119,9 @@ RSpec.describe ImportService, type: :service do it 'mutes the listed accounts, including notifications' do account.follow!(bob, reblogs: false) subject.call(import) - expect(account.following.count).to eq 2 + expect(account.following.count).to eq 1 expect(Follow.find_by(account: account, target_account: bob).show_reblogs).to be true + expect(FollowRequest.find_by(account: account, target_account: foo)).to_not be_nil end end end @@ -128,17 +131,13 @@ RSpec.describe ImportService, type: :service do let(:csv) { attachment_fixture('new-following-imports.txt') } - before do - allow(NotificationWorker).to receive(:perform_async) - end - describe 'when no accounts are followed' do let(:import) { Import.create(account: account, type: 'following', data: csv) } it 'follows the listed accounts, respecting boosts' do subject.call(import) - expect(account.following.count).to eq 2 + expect(account.following.count).to eq 1 expect(Follow.find_by(account: account, target_account: bob).show_reblogs).to be true - expect(Follow.find_by(account: account, target_account: eve).show_reblogs).to be false + expect(FollowRequest.find_by(account: account, target_account: foo)).to_not be_nil end end @@ -148,9 +147,9 @@ RSpec.describe ImportService, type: :service do it 'mutes the listed accounts, respecting notifications' do account.follow!(bob, reblogs: true) subject.call(import) - expect(account.following.count).to eq 2 + expect(account.following.count).to eq 1 expect(Follow.find_by(account: account, target_account: bob).show_reblogs).to be true - expect(Follow.find_by(account: account, target_account: eve).show_reblogs).to be false + expect(FollowRequest.find_by(account: account, target_account: foo)).to_not be_nil end end @@ -160,9 +159,9 @@ RSpec.describe ImportService, type: :service do it 'mutes the listed accounts, respecting notifications' do account.follow!(bob, reblogs: true) subject.call(import) - expect(account.following.count).to eq 2 + expect(account.following.count).to eq 1 expect(Follow.find_by(account: account, target_account: bob).show_reblogs).to be true - expect(Follow.find_by(account: account, target_account: eve).show_reblogs).to be false + expect(FollowRequest.find_by(account: account, target_account: foo)).to_not be_nil end end end |