about summary refs log tree commit diff
path: root/spec/models/public_feed_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/models/public_feed_spec.rb')
-rw-r--r--spec/models/public_feed_spec.rb62
1 files changed, 62 insertions, 0 deletions
diff --git a/spec/models/public_feed_spec.rb b/spec/models/public_feed_spec.rb
index 0392a582c..c251953a4 100644
--- a/spec/models/public_feed_spec.rb
+++ b/spec/models/public_feed_spec.rb
@@ -47,6 +47,7 @@ RSpec.describe PublicFeed, type: :model do
       let!(:remote_account) { Fabricate(:account, domain: 'test.com') }
       let!(:local_status)   { Fabricate(:status, account: local_account) }
       let!(:remote_status)  { Fabricate(:status, account: remote_account) }
+      let!(:local_only_status) { Fabricate(:status, account: local_account, local_only: true) }
 
       subject { described_class.new(viewer).get(20).map(&:id) }
 
@@ -60,6 +61,10 @@ RSpec.describe PublicFeed, type: :model do
         it 'includes local statuses' do
           expect(subject).to include(local_status.id)
         end
+
+        it 'does not include local-only statuses' do
+          expect(subject).not_to include(local_only_status.id)
+        end
       end
 
       context 'with a viewer' do
@@ -72,6 +77,54 @@ RSpec.describe PublicFeed, type: :model do
         it 'includes local statuses' do
           expect(subject).to include(local_status.id)
         end
+
+        it 'does not include local-only statuses' do
+          expect(subject).not_to include(local_only_status.id)
+        end
+      end
+    end
+
+    context 'without local_only option but allow_local_only' do
+      let(:viewer) { nil }
+
+      let!(:local_account)  { Fabricate(:account, domain: nil) }
+      let!(:remote_account) { Fabricate(:account, domain: 'test.com') }
+      let!(:local_status)   { Fabricate(:status, account: local_account) }
+      let!(:remote_status)  { Fabricate(:status, account: remote_account) }
+      let!(:local_only_status) { Fabricate(:status, account: local_account, local_only: true) }
+
+      subject { described_class.new(viewer, allow_local_only: true).get(20).map(&:id) }
+
+      context 'without a viewer' do
+        let(:viewer) { nil }
+
+        it 'includes remote instances statuses' do
+          expect(subject).to include(remote_status.id)
+        end
+
+        it 'includes local statuses' do
+          expect(subject).to include(local_status.id)
+        end
+
+        it 'does not include local-only statuses' do
+          expect(subject).not_to include(local_only_status.id)
+        end
+      end
+
+      context 'with a viewer' do
+        let(:viewer) { Fabricate(:account, username: 'viewer') }
+
+        it 'includes remote instances statuses' do
+          expect(subject).to include(remote_status.id)
+        end
+
+        it 'includes local statuses' do
+          expect(subject).to include(local_status.id)
+        end
+
+        it 'includes local-only statuses' do
+          expect(subject).to include(local_only_status.id)
+        end
       end
     end
 
@@ -80,6 +133,7 @@ RSpec.describe PublicFeed, type: :model do
       let!(:remote_account) { Fabricate(:account, domain: 'test.com') }
       let!(:local_status)   { Fabricate(:status, account: local_account) }
       let!(:remote_status)  { Fabricate(:status, account: remote_account) }
+      let!(:local_only_status) { Fabricate(:status, account: local_account, local_only: true) }
 
       subject { described_class.new(viewer, local: true).get(20).map(&:id) }
 
@@ -90,6 +144,10 @@ RSpec.describe PublicFeed, type: :model do
           expect(subject).to include(local_status.id)
           expect(subject).not_to include(remote_status.id)
         end
+
+        it 'does not include local-only statuses' do
+          expect(subject).not_to include(local_only_status.id)
+        end
       end
 
       context 'with a viewer' do
@@ -105,6 +163,10 @@ RSpec.describe PublicFeed, type: :model do
           expect(subject).to include(local_status.id)
           expect(subject).not_to include(remote_status.id)
         end
+
+        it 'includes local-only statuses' do
+          expect(subject).to include(local_only_status.id)
+        end
       end
     end