about summary refs log tree commit diff
path: root/spec
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2017-05-20 16:56:30 +0200
committerGitHub <noreply@github.com>2017-05-20 16:56:30 +0200
commitd3be2b582af0c3b7d21d5b3caa02e83d17fe1240 (patch)
tree4ab8b88807adf5a95a6672b22a403f4eaf784c6b /spec
parent419226d1f6ceb59958b15a56c1109750b1cb9860 (diff)
More tests for public timeline method (#3171)
Diffstat (limited to 'spec')
-rw-r--r--spec/models/status_spec.rb73
1 files changed, 64 insertions, 9 deletions
diff --git a/spec/models/status_spec.rb b/spec/models/status_spec.rb
index 97ed94149..e9e55a92b 100644
--- a/spec/models/status_spec.rb
+++ b/spec/models/status_spec.rb
@@ -401,16 +401,71 @@ RSpec.describe Status, type: :model do
       expect(results).not_to include(silenced_status)
     end
 
+    context 'without local_only option' 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) }
+
+      subject { Status.as_public_timeline(viewer, false) }
+
+      context 'without a viewer' do
+        let(:viewer) { nil }
+
+        it 'includes remote instances statuses' do
+          expect(subject).to include(remote_status)
+        end
+
+        it 'includes local statuses' do
+          expect(subject).to include(local_status)
+        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)
+        end
+
+        it 'includes local statuses' do
+          expect(subject).to include(local_status)
+        end
+      end
+    end
+
     context 'with a local_only option set' do
-      it 'does not include remote instances statuses' do
-        local_account = Fabricate(:account, domain: nil)
-        remote_account = Fabricate(:account, domain: 'test.com')
-        local_status = Fabricate(:status, account: local_account)
-        remote_status = Fabricate(:status, account: remote_account)
-
-        results = Status.as_public_timeline(nil, true)
-        expect(results).to include(local_status)
-        expect(results).not_to include(remote_status)
+      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) }
+
+      subject { Status.as_public_timeline(viewer, true) }
+
+      context 'without a viewer' do
+        let(:viewer) { nil }
+
+        it 'does not include remote instances statuses' do
+          expect(subject).to include(local_status)
+          expect(subject).not_to include(remote_status)
+        end
+      end
+
+      context 'with a viewer' do
+        let(:viewer) { Fabricate(:account, username: 'viewer') }
+
+        it 'does not include remote instances statuses' do
+          expect(subject).to include(local_status)
+          expect(subject).not_to include(remote_status)
+        end
+
+        it 'is not affected by personal domain blocks' do
+          viewer.block_domain!('test.com')
+          expect(subject).to include(local_status)
+          expect(subject).not_to include(remote_status)
+        end
       end
     end