about summary refs log tree commit diff
path: root/spec/workers
diff options
context:
space:
mode:
authorClaire <claire.github-309c@sitedethib.com>2022-02-10 19:09:27 +0100
committerClaire <claire.github-309c@sitedethib.com>2022-02-10 19:09:27 +0100
commitf1a6f9062e00c0651680bf4d5d750ec0b078ac5a (patch)
tree30d40f0b5df56e955f80a91ae3b44090bd918ed9 /spec/workers
parentd602c92b310545eb733a58caed49717341abe27c (diff)
parent3dc1e3cfc3928ce709c3e60e98ecbd1edd6e2a7d (diff)
Merge branch 'main' into glitch-soc/merge-upstream
Conflicts:
- `app/controllers/api/v1/statuses_controller.rb`:
  Upstream moved things around in a place where glitch-soc had support for
  an extra parameter (`content_type`).
  Follow upstream but reintroduce `content_type`.
Diffstat (limited to 'spec/workers')
-rw-r--r--spec/workers/activitypub/status_update_distribution_worker_spec.rb48
1 files changed, 48 insertions, 0 deletions
diff --git a/spec/workers/activitypub/status_update_distribution_worker_spec.rb b/spec/workers/activitypub/status_update_distribution_worker_spec.rb
new file mode 100644
index 000000000..6633b601f
--- /dev/null
+++ b/spec/workers/activitypub/status_update_distribution_worker_spec.rb
@@ -0,0 +1,48 @@
+require 'rails_helper'
+
+describe ActivityPub::StatusUpdateDistributionWorker do
+  subject { described_class.new }
+
+  let(:status)   { Fabricate(:status, text: 'foo') }
+  let(:follower) { Fabricate(:account, protocol: :activitypub, inbox_url: 'http://example.com') }
+
+  describe '#perform' do
+    before do
+      follower.follow!(status.account)
+
+      status.snapshot!
+      status.text = 'bar'
+      status.edited_at = Time.now.utc
+      status.snapshot!
+      status.save!
+    end
+
+    context 'with public status' do
+      before do
+        status.update(visibility: :public)
+      end
+
+      it 'delivers to followers' do
+        expect(ActivityPub::DeliveryWorker).to receive(:push_bulk) do |items, &block|
+          expect(items.map(&block)).to match([[kind_of(String), status.account.id, 'http://example.com', anything]])
+        end
+
+        subject.perform(status.id)
+      end
+    end
+
+    context 'with private status' do
+      before do
+        status.update(visibility: :private)
+      end
+
+      it 'delivers to followers' do
+        expect(ActivityPub::DeliveryWorker).to receive(:push_bulk) do |items, &block|
+          expect(items.map(&block)).to match([[kind_of(String), status.account.id, 'http://example.com', anything]])
+        end
+
+        subject.perform(status.id)
+      end
+    end
+  end
+end