about summary refs log tree commit diff
path: root/spec/workers
diff options
context:
space:
mode:
Diffstat (limited to 'spec/workers')
-rw-r--r--spec/workers/digest_mailer_worker_spec.rb36
-rw-r--r--spec/workers/move_worker_spec.rb15
-rw-r--r--spec/workers/refollow_worker_spec.rb4
-rw-r--r--spec/workers/scheduler/feed_cleanup_scheduler_spec.rb26
-rw-r--r--spec/workers/scheduler/media_cleanup_scheduler_spec.rb15
5 files changed, 17 insertions, 79 deletions
diff --git a/spec/workers/digest_mailer_worker_spec.rb b/spec/workers/digest_mailer_worker_spec.rb
deleted file mode 100644
index db3b1390d..000000000
--- a/spec/workers/digest_mailer_worker_spec.rb
+++ /dev/null
@@ -1,36 +0,0 @@
-# frozen_string_literal: true
-
-require 'rails_helper'
-
-describe DigestMailerWorker do
-  describe 'perform' do
-    let(:user) { Fabricate(:user, last_emailed_at: 3.days.ago) }
-
-    context 'for a user who receives digests' do
-      it 'sends the email' do
-        service = double(deliver_now!: nil)
-        allow(NotificationMailer).to receive(:digest).and_return(service)
-        update_user_digest_setting(true)
-        described_class.perform_async(user.id)
-
-        expect(NotificationMailer).to have_received(:digest)
-        expect(user.reload.last_emailed_at).to be_within(1).of(Time.now.utc)
-      end
-    end
-
-    context 'for a user who does not receive digests' do
-      it 'does not send the email' do
-        allow(NotificationMailer).to receive(:digest)
-        update_user_digest_setting(false)
-        described_class.perform_async(user.id)
-
-        expect(NotificationMailer).not_to have_received(:digest)
-        expect(user.last_emailed_at).to be_within(1).of(3.days.ago)
-      end
-    end
-
-    def update_user_digest_setting(value)
-      user.settings['notification_emails'] = user.settings['notification_emails'].merge('digest' => value)
-    end
-  end
-end
diff --git a/spec/workers/move_worker_spec.rb b/spec/workers/move_worker_spec.rb
index be02d3192..3ca6aaf4d 100644
--- a/spec/workers/move_worker_spec.rb
+++ b/spec/workers/move_worker_spec.rb
@@ -74,6 +74,18 @@ describe MoveWorker do
     end
   end
 
+  shared_examples 'followers count handling' do
+    it 'updates the source account followers count' do
+      subject.perform(source_account.id, target_account.id)
+      expect(source_account.reload.followers_count).to eq(source_account.passive_relationships.count)
+    end
+
+    it 'updates the target account followers count' do
+      subject.perform(source_account.id, target_account.id)
+      expect(target_account.reload.followers_count).to eq(target_account.passive_relationships.count)
+    end
+  end
+
   context 'both accounts are distant' do
     describe 'perform' do
       it 'calls UnfollowFollowWorker' do
@@ -83,6 +95,7 @@ describe MoveWorker do
 
       include_examples 'user note handling'
       include_examples 'block and mute handling'
+      include_examples 'followers count handling'
     end
   end
 
@@ -97,6 +110,7 @@ describe MoveWorker do
 
       include_examples 'user note handling'
       include_examples 'block and mute handling'
+      include_examples 'followers count handling'
     end
   end
 
@@ -112,6 +126,7 @@ describe MoveWorker do
 
       include_examples 'user note handling'
       include_examples 'block and mute handling'
+      include_examples 'followers count handling'
 
       it 'does not fail when a local user is already following both accounts' do
         double_follower = Fabricate(:account)
diff --git a/spec/workers/refollow_worker_spec.rb b/spec/workers/refollow_worker_spec.rb
index df6731b64..d9c2293b6 100644
--- a/spec/workers/refollow_worker_spec.rb
+++ b/spec/workers/refollow_worker_spec.rb
@@ -23,8 +23,8 @@ describe RefollowWorker do
       result = subject.perform(account.id)
 
       expect(result).to be_nil
-      expect(service).to have_received(:call).with(alice, account, reblogs: true, notify: false, bypass_limit: true)
-      expect(service).to have_received(:call).with(bob, account, reblogs: false, notify: false, bypass_limit: true)
+      expect(service).to have_received(:call).with(alice, account, reblogs: true, notify: false, languages: nil, bypass_limit: true)
+      expect(service).to have_received(:call).with(bob, account, reblogs: false, notify: false, languages: nil, bypass_limit: true)
     end
   end
 end
diff --git a/spec/workers/scheduler/feed_cleanup_scheduler_spec.rb b/spec/workers/scheduler/feed_cleanup_scheduler_spec.rb
deleted file mode 100644
index 82d794594..000000000
--- a/spec/workers/scheduler/feed_cleanup_scheduler_spec.rb
+++ /dev/null
@@ -1,26 +0,0 @@
-require 'rails_helper'
-
-describe Scheduler::FeedCleanupScheduler do
-  subject { described_class.new }
-
-  let!(:active_user) { Fabricate(:user, current_sign_in_at: 2.days.ago) }
-  let!(:inactive_user) { Fabricate(:user, current_sign_in_at: 22.days.ago) }
-
-  it 'clears feeds of inactives' do
-    redis.zadd(feed_key_for(inactive_user), 1, 1)
-    redis.zadd(feed_key_for(active_user), 1, 1)
-    redis.zadd(feed_key_for(inactive_user, 'reblogs'), 2, 2)
-    redis.sadd(feed_key_for(inactive_user, 'reblogs:2'), 3)
-
-    subject.perform
-
-    expect(redis.zcard(feed_key_for(inactive_user))).to eq 0
-    expect(redis.zcard(feed_key_for(active_user))).to eq 1
-    expect(redis.exists?(feed_key_for(inactive_user, 'reblogs'))).to be false
-    expect(redis.exists?(feed_key_for(inactive_user, 'reblogs:2'))).to be false
-  end
-
-  def feed_key_for(user, subtype = nil)
-    FeedManager.instance.key(:home, user.account_id, subtype)
-  end
-end
diff --git a/spec/workers/scheduler/media_cleanup_scheduler_spec.rb b/spec/workers/scheduler/media_cleanup_scheduler_spec.rb
deleted file mode 100644
index 8a0da67e1..000000000
--- a/spec/workers/scheduler/media_cleanup_scheduler_spec.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-require 'rails_helper'
-
-describe Scheduler::MediaCleanupScheduler do
-  subject { described_class.new }
-
-  let!(:old_media) { Fabricate(:media_attachment, account_id: nil, created_at: 10.days.ago) }
-  let!(:new_media) { Fabricate(:media_attachment, account_id: nil, created_at: 1.hour.ago) }
-
-  it 'removes old media records' do
-    subject.perform
-
-    expect { old_media.reload }.to raise_error(ActiveRecord::RecordNotFound)
-    expect(new_media.reload).to be_persisted
-  end
-end