diff options
Diffstat (limited to 'spec/models/public_feed_spec.rb')
-rw-r--r-- | spec/models/public_feed_spec.rb | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/spec/models/public_feed_spec.rb b/spec/models/public_feed_spec.rb index 5653aee18..f607f10ec 100644 --- a/spec/models/public_feed_spec.rb +++ b/spec/models/public_feed_spec.rb @@ -50,6 +50,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) } context 'without a viewer' do let(:viewer) { nil } @@ -61,6 +62,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 @@ -73,6 +78,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 @@ -83,6 +136,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) } context 'without a viewer' do let(:viewer) { nil } @@ -91,6 +145,10 @@ RSpec.describe PublicFeed, type: :model do expect(subject).to include(local_status.id) expect(subject).to_not 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 @@ -106,6 +164,10 @@ RSpec.describe PublicFeed, type: :model do expect(subject).to include(local_status.id) expect(subject).to_not include(remote_status.id) end + + it 'includes local-only statuses' do + expect(subject).to include(local_only_status.id) + end end end |