about summary refs log tree commit diff
path: root/spec
diff options
context:
space:
mode:
authorThibaut Girka <thib@sitedethib.com>2020-09-08 16:01:55 +0200
committerThibaut Girka <thib@sitedethib.com>2020-09-08 16:26:47 +0200
commit9748f074a385fce5ad6913b1a22fb7ea9e7566db (patch)
treeccd775be4b73170fcbf45407b84ad35fc37fb853 /spec
parent437d71bddf967573df3912ee5976f7c5a5a7b4c7 (diff)
parent65760f59df46e388919a9f7ccba1958d967b2695 (diff)
Merge branch 'master' into glitch-soc/merge-upstream
Conflicts:
- app/controllers/api/v1/timelines/public_controller.rb
- app/lib/feed_manager.rb
- app/models/status.rb
- app/services/precompute_feed_service.rb
- app/workers/feed_insert_worker.rb
- spec/models/status_spec.rb

All conflicts are due to upstream refactoring feed management and us having
local-only toots on top of that. Rewrote local-only toots management for
upstream's changes.
Diffstat (limited to 'spec')
-rw-r--r--spec/lib/feed_manager_spec.rb90
-rw-r--r--spec/models/public_feed_spec.rb274
-rw-r--r--spec/models/status_spec.rb282
-rw-r--r--spec/models/tag_feed_spec.rb (renamed from spec/services/hashtag_query_service_spec.rb)40
-rw-r--r--spec/services/fan_out_on_write_service_spec.rb4
5 files changed, 336 insertions, 354 deletions
diff --git a/spec/lib/feed_manager_spec.rb b/spec/lib/feed_manager_spec.rb
index bb5bdfdc5..22c9ff31b 100644
--- a/spec/lib/feed_manager_spec.rb
+++ b/spec/lib/feed_manager_spec.rb
@@ -29,14 +29,14 @@ RSpec.describe FeedManager do
       it 'returns false for followee\'s status' do
         status = Fabricate(:status, text: 'Hello world', account: alice)
         bob.follow!(alice)
-        expect(FeedManager.instance.filter?(:home, status, bob.id)).to be false
+        expect(FeedManager.instance.filter?(:home, status, bob)).to be false
       end
 
       it 'returns false for reblog by followee' do
         status = Fabricate(:status, text: 'Hello world', account: jeff)
         reblog = Fabricate(:status, reblog: status, account: alice)
         bob.follow!(alice)
-        expect(FeedManager.instance.filter?(:home, reblog, bob.id)).to be false
+        expect(FeedManager.instance.filter?(:home, reblog, bob)).to be false
       end
 
       it 'returns true for reblog by followee of blocked account' do
@@ -44,7 +44,7 @@ RSpec.describe FeedManager do
         reblog = Fabricate(:status, reblog: status, account: alice)
         bob.follow!(alice)
         bob.block!(jeff)
-        expect(FeedManager.instance.filter?(:home, reblog, bob.id)).to be true
+        expect(FeedManager.instance.filter?(:home, reblog, bob)).to be true
       end
 
       it 'returns true for reblog by followee of muted account' do
@@ -52,7 +52,7 @@ RSpec.describe FeedManager do
         reblog = Fabricate(:status, reblog: status, account: alice)
         bob.follow!(alice)
         bob.mute!(jeff)
-        expect(FeedManager.instance.filter?(:home, reblog, bob.id)).to be true
+        expect(FeedManager.instance.filter?(:home, reblog, bob)).to be true
       end
 
       it 'returns true for reblog by followee of someone who is blocking recipient' do
@@ -60,14 +60,14 @@ RSpec.describe FeedManager do
         reblog = Fabricate(:status, reblog: status, account: alice)
         bob.follow!(alice)
         jeff.block!(bob)
-        expect(FeedManager.instance.filter?(:home, reblog, bob.id)).to be true
+        expect(FeedManager.instance.filter?(:home, reblog, bob)).to be true
       end
 
       it 'returns true for reblog from account with reblogs disabled' do
         status = Fabricate(:status, text: 'Hello world', account: jeff)
         reblog = Fabricate(:status, reblog: status, account: alice)
         bob.follow!(alice, reblogs: false)
-        expect(FeedManager.instance.filter?(:home, reblog, bob.id)).to be true
+        expect(FeedManager.instance.filter?(:home, reblog, bob)).to be true
       end
 
       it 'returns false for reply by followee to another followee' do
@@ -75,55 +75,55 @@ RSpec.describe FeedManager do
         reply  = Fabricate(:status, text: 'Nay', thread: status, account: alice)
         bob.follow!(alice)
         bob.follow!(jeff)
-        expect(FeedManager.instance.filter?(:home, reply, bob.id)).to be false
+        expect(FeedManager.instance.filter?(:home, reply, bob)).to be false
       end
 
       it 'returns false for reply by followee to recipient' do
         status = Fabricate(:status, text: 'Hello world', account: bob)
         reply  = Fabricate(:status, text: 'Nay', thread: status, account: alice)
         bob.follow!(alice)
-        expect(FeedManager.instance.filter?(:home, reply, bob.id)).to be false
+        expect(FeedManager.instance.filter?(:home, reply, bob)).to be false
       end
 
       it 'returns false for reply by followee to self' do
         status = Fabricate(:status, text: 'Hello world', account: alice)
         reply  = Fabricate(:status, text: 'Nay', thread: status, account: alice)
         bob.follow!(alice)
-        expect(FeedManager.instance.filter?(:home, reply, bob.id)).to be false
+        expect(FeedManager.instance.filter?(:home, reply, bob)).to be false
       end
 
       it 'returns true for reply by followee to non-followed account' do
         status = Fabricate(:status, text: 'Hello world', account: jeff)
         reply  = Fabricate(:status, text: 'Nay', thread: status, account: alice)
         bob.follow!(alice)
-        expect(FeedManager.instance.filter?(:home, reply, bob.id)).to be true
+        expect(FeedManager.instance.filter?(:home, reply, bob)).to be true
       end
 
       it 'returns true for the second reply by followee to a non-federated status' do
         reply        = Fabricate(:status, text: 'Reply 1', reply: true, account: alice)
         second_reply = Fabricate(:status, text: 'Reply 2', thread: reply, account: alice)
         bob.follow!(alice)
-        expect(FeedManager.instance.filter?(:home, second_reply, bob.id)).to be true
+        expect(FeedManager.instance.filter?(:home, second_reply, bob)).to be true
       end
 
       it 'returns false for status by followee mentioning another account' do
         bob.follow!(alice)
         status = PostStatusService.new.call(alice, text: 'Hey @jeff')
-        expect(FeedManager.instance.filter?(:home, status, bob.id)).to be false
+        expect(FeedManager.instance.filter?(:home, status, bob)).to be false
       end
 
       it 'returns true for status by followee mentioning blocked account' do
         bob.block!(jeff)
         bob.follow!(alice)
         status = PostStatusService.new.call(alice, text: 'Hey @jeff')
-        expect(FeedManager.instance.filter?(:home, status, bob.id)).to be true
+        expect(FeedManager.instance.filter?(:home, status, bob)).to be true
       end
 
       it 'returns true for status by followee mentioning muted account' do
         bob.mute!(jeff)
         bob.follow!(alice)
         status = PostStatusService.new.call(alice, text: 'Hey @jeff')
-        expect(FeedManager.instance.filter?(:home, status, bob.id)).to be true
+        expect(FeedManager.instance.filter?(:home, status, bob)).to be true
       end
 
       it 'returns true for reblog of a personally blocked domain' do
@@ -131,7 +131,7 @@ RSpec.describe FeedManager do
         alice.follow!(jeff)
         status = Fabricate(:status, text: 'Hello world', account: bob)
         reblog = Fabricate(:status, reblog: status, account: jeff)
-        expect(FeedManager.instance.filter?(:home, reblog, alice.id)).to be true
+        expect(FeedManager.instance.filter?(:home, reblog, alice)).to be true
       end
 
       context 'for irreversibly muted phrases' do
@@ -139,7 +139,7 @@ RSpec.describe FeedManager do
           alice.custom_filters.create!(phrase: 'bob', context: %w(home), irreversible: true)
           alice.follow!(jeff)
           status = Fabricate(:status, text: 'bobcats', account: jeff)
-          expect(FeedManager.instance.filter?(:home, status, alice.id)).to be_falsy
+          expect(FeedManager.instance.filter?(:home, status, alice)).to be_falsy
         end
 
         it 'returns true if phrase is contained' do
@@ -147,14 +147,14 @@ RSpec.describe FeedManager do
           alice.custom_filters.create!(phrase: 'pop tarts', context: %w(home), irreversible: true)
           alice.follow!(jeff)
           status = Fabricate(:status, text: 'i sure like POP TARts', account: jeff)
-          expect(FeedManager.instance.filter?(:home, status, alice.id)).to be true
+          expect(FeedManager.instance.filter?(:home, status, alice)).to be true
         end
 
         it 'matches substrings if whole_word is false' do
           alice.custom_filters.create!(phrase: 'take', context: %w(home), whole_word: false, irreversible: true)
           alice.follow!(jeff)
           status = Fabricate(:status, text: 'shiitake', account: jeff)
-          expect(FeedManager.instance.filter?(:home, status, alice.id)).to be true
+          expect(FeedManager.instance.filter?(:home, status, alice)).to be true
         end
 
         it 'returns true if phrase is contained in a poll option' do
@@ -162,7 +162,7 @@ RSpec.describe FeedManager do
           alice.custom_filters.create!(phrase: 'pop tarts', context: %w(home), irreversible: true)
           alice.follow!(jeff)
           status = Fabricate(:status, text: 'what do you prefer', poll: Fabricate(:poll, options: %w(farts POP TARts)), account: jeff)
-          expect(FeedManager.instance.filter?(:home, status, alice.id)).to be true
+          expect(FeedManager.instance.filter?(:home, status, alice)).to be true
         end
       end
     end
@@ -171,27 +171,27 @@ RSpec.describe FeedManager do
       it 'returns true for status that mentions blocked account' do
         bob.block!(jeff)
         status = PostStatusService.new.call(alice, text: 'Hey @jeff')
-        expect(FeedManager.instance.filter?(:mentions, status, bob.id)).to be true
+        expect(FeedManager.instance.filter?(:mentions, status, bob)).to be true
       end
 
       it 'returns true for status that replies to a blocked account' do
         status = Fabricate(:status, text: 'Hello world', account: jeff)
         reply  = Fabricate(:status, text: 'Nay', thread: status, account: alice)
         bob.block!(jeff)
-        expect(FeedManager.instance.filter?(:mentions, reply, bob.id)).to be true
+        expect(FeedManager.instance.filter?(:mentions, reply, bob)).to be true
       end
 
       it 'returns true for status by silenced account who recipient is not following' do
         status = Fabricate(:status, text: 'Hello world', account: alice)
         alice.silence!
-        expect(FeedManager.instance.filter?(:mentions, status, bob.id)).to be true
+        expect(FeedManager.instance.filter?(:mentions, status, bob)).to be true
       end
 
       it 'returns false for status by followed silenced account' do
         status = Fabricate(:status, text: 'Hello world', account: alice)
         alice.silence!
         bob.follow!(alice)
-        expect(FeedManager.instance.filter?(:mentions, status, bob.id)).to be false
+        expect(FeedManager.instance.filter?(:mentions, status, bob)).to be false
       end
     end
   end
@@ -421,52 +421,20 @@ RSpec.describe FeedManager do
     end
   end
 
-  describe '#merge_into_timeline' do
+  describe '#merge_into_home' do
     it "does not push source account's statuses whose reblogs are already inserted" do
       account = Fabricate(:account, id: 0)
       reblog = Fabricate(:status)
       status = Fabricate(:status, reblog: reblog)
       FeedManager.instance.push_to_home(account, status)
 
-      FeedManager.instance.merge_into_timeline(account, reblog.account)
+      FeedManager.instance.merge_into_home(account, reblog.account)
 
       expect(Redis.current.zscore("feed:home:0", reblog.id)).to eq nil
     end
   end
 
-  describe '#trim' do
-    let(:receiver) { Fabricate(:account) }
-
-    it 'cleans up reblog tracking keys' do
-      reblogged      = Fabricate(:status)
-      status         = Fabricate(:status, reblog: reblogged)
-      another_status = Fabricate(:status, reblog: reblogged)
-      reblogs_key    = FeedManager.instance.key('home', receiver.id, 'reblogs')
-      reblog_set_key = FeedManager.instance.key('home', receiver.id, "reblogs:#{reblogged.id}")
-
-      FeedManager.instance.push_to_home(receiver, status)
-      FeedManager.instance.push_to_home(receiver, another_status)
-
-      # We should have a tracking set and an entry in reblogs.
-      expect(Redis.current.exists?(reblog_set_key)).to be true
-      expect(Redis.current.zrange(reblogs_key, 0, -1)).to eq [reblogged.id.to_s]
-
-      # Push everything off the end of the feed.
-      FeedManager::MAX_ITEMS.times do
-        FeedManager.instance.push_to_home(receiver, Fabricate(:status))
-      end
-
-      # `trim` should be called automatically, but do it anyway, as
-      # we're testing `trim`, not side effects of `push`.
-      FeedManager.instance.trim('home', receiver.id)
-
-      # We should not have any reblog tracking data.
-      expect(Redis.current.exists?(reblog_set_key)).to be false
-      expect(Redis.current.zrange(reblogs_key, 0, -1)).to be_empty
-    end
-  end
-
-  describe '#unpush' do
+  describe '#unpush_from_home' do
     let(:receiver) { Fabricate(:account) }
 
     it 'leaves a reblogged status if original was on feed' do
@@ -532,7 +500,7 @@ RSpec.describe FeedManager do
     end
   end
 
-  describe '#clear_from_timeline' do
+  describe '#clear_from_home' do
     let(:account)          { Fabricate(:account) }
     let(:followed_account) { Fabricate(:account) }
     let(:target_account)   { Fabricate(:account) }
@@ -550,8 +518,8 @@ RSpec.describe FeedManager do
       end
     end
 
-    it 'correctly cleans the timeline' do
-      FeedManager.instance.clear_from_timeline(account, target_account)
+    it 'correctly cleans the home timeline' do
+      FeedManager.instance.clear_from_home(account, target_account)
 
       expect(Redis.current.zrange("feed:home:#{account.id}", 0, -1)).to eq [status_1.id.to_s, status_7.id.to_s]
     end
diff --git a/spec/models/public_feed_spec.rb b/spec/models/public_feed_spec.rb
new file mode 100644
index 000000000..c251953a4
--- /dev/null
+++ b/spec/models/public_feed_spec.rb
@@ -0,0 +1,274 @@
+require 'rails_helper'
+
+RSpec.describe PublicFeed, type: :model do
+  let(:account) { Fabricate(:account) }
+
+  describe '#get' do
+    subject { described_class.new(nil).get(20).map(&:id) }
+
+    it 'only includes statuses with public visibility' do
+      public_status = Fabricate(:status, visibility: :public)
+      private_status = Fabricate(:status, visibility: :private)
+
+      expect(subject).to include(public_status.id)
+      expect(subject).not_to include(private_status.id)
+    end
+
+    it 'does not include replies' do
+      status = Fabricate(:status)
+      reply = Fabricate(:status, in_reply_to_id: status.id)
+
+      expect(subject).to include(status.id)
+      expect(subject).not_to include(reply.id)
+    end
+
+    it 'does not include boosts' do
+      status = Fabricate(:status)
+      boost = Fabricate(:status, reblog_of_id: status.id)
+
+      expect(subject).to include(status.id)
+      expect(subject).not_to include(boost.id)
+    end
+
+    it 'filters out silenced accounts' do
+      account = Fabricate(:account)
+      silenced_account = Fabricate(:account, silenced: true)
+      status = Fabricate(:status, account: account)
+      silenced_status = Fabricate(:status, account: silenced_account)
+
+      expect(subject).to include(status.id)
+      expect(subject).not_to include(silenced_status.id)
+    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) }
+      let!(:local_only_status) { Fabricate(:status, account: local_account, local_only: true) }
+
+      subject { described_class.new(viewer).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 '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
+
+    context 'with a local_only option set' do
+      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, local: true).get(20).map(&:id) }
+
+      context 'without a viewer' do
+        let(:viewer) { nil }
+
+        it 'does not include remote instances statuses' 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
+        let(:viewer) { Fabricate(:account, username: 'viewer') }
+
+        it 'does not include remote instances statuses' do
+          expect(subject).to include(local_status.id)
+          expect(subject).not_to include(remote_status.id)
+        end
+
+        it 'is not affected by personal domain blocks' do
+          viewer.block_domain!('test.com')
+          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
+
+    context 'with a remote_only option set' do
+      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 { described_class.new(viewer, remote: true).get(20).map(&:id) }
+
+      context 'without a viewer' do
+        let(:viewer) { nil }
+
+        it 'does not include local instances statuses' do
+          expect(subject).not_to include(local_status.id)
+          expect(subject).to include(remote_status.id)
+        end
+      end
+
+      context 'with a viewer' do
+        let(:viewer) { Fabricate(:account, username: 'viewer') }
+
+        it 'does not include local instances statuses' do
+          expect(subject).not_to include(local_status.id)
+          expect(subject).to include(remote_status.id)
+        end
+      end
+    end
+
+    describe 'with an account passed in' do
+      before do
+        @account = Fabricate(:account)
+      end
+
+      subject { described_class.new(@account).get(20).map(&:id) }
+
+      it 'excludes statuses from accounts blocked by the account' do
+        blocked = Fabricate(:account)
+        @account.block!(blocked)
+        blocked_status = Fabricate(:status, account: blocked)
+
+        expect(subject).not_to include(blocked_status.id)
+      end
+
+      it 'excludes statuses from accounts who have blocked the account' do
+        blocker = Fabricate(:account)
+        blocker.block!(@account)
+        blocked_status = Fabricate(:status, account: blocker)
+
+        expect(subject).not_to include(blocked_status.id)
+      end
+
+      it 'excludes statuses from accounts muted by the account' do
+        muted = Fabricate(:account)
+        @account.mute!(muted)
+        muted_status = Fabricate(:status, account: muted)
+
+        expect(subject).not_to include(muted_status.id)
+      end
+
+      it 'excludes statuses from accounts from personally blocked domains' do
+        blocked = Fabricate(:account, domain: 'example.com')
+        @account.block_domain!(blocked.domain)
+        blocked_status = Fabricate(:status, account: blocked)
+
+        expect(subject).not_to include(blocked_status.id)
+      end
+
+      context 'with language preferences' do
+        it 'excludes statuses in languages not allowed by the account user' do
+          user = Fabricate(:user, chosen_languages: [:en, :es])
+          @account.update(user: user)
+          en_status = Fabricate(:status, language: 'en')
+          es_status = Fabricate(:status, language: 'es')
+          fr_status = Fabricate(:status, language: 'fr')
+
+          expect(subject).to include(en_status.id)
+          expect(subject).to include(es_status.id)
+          expect(subject).not_to include(fr_status.id)
+        end
+
+        it 'includes all languages when user does not have a setting' do
+          user = Fabricate(:user, chosen_languages: nil)
+          @account.update(user: user)
+
+          en_status = Fabricate(:status, language: 'en')
+          es_status = Fabricate(:status, language: 'es')
+
+          expect(subject).to include(en_status.id)
+          expect(subject).to include(es_status.id)
+        end
+
+        it 'includes all languages when account does not have a user' do
+          expect(@account.user).to be_nil
+          en_status = Fabricate(:status, language: 'en')
+          es_status = Fabricate(:status, language: 'es')
+
+          expect(subject).to include(en_status.id)
+          expect(subject).to include(es_status.id)
+        end
+      end
+    end
+  end
+end
diff --git a/spec/models/status_spec.rb b/spec/models/status_spec.rb
index 041021d34..c1375ea94 100644
--- a/spec/models/status_spec.rb
+++ b/spec/models/status_spec.rb
@@ -354,288 +354,6 @@ RSpec.describe Status, type: :model do
     end
   end
 
-  describe '.as_public_timeline' do
-    it 'only includes statuses with public visibility' do
-      public_status = Fabricate(:status, visibility: :public)
-      private_status = Fabricate(:status, visibility: :private)
-
-      results = Status.as_public_timeline
-      expect(results).to include(public_status)
-      expect(results).not_to include(private_status)
-    end
-
-    it 'does not include replies' do
-      status = Fabricate(:status)
-      reply = Fabricate(:status, in_reply_to_id: status.id)
-
-      results = Status.as_public_timeline
-      expect(results).to include(status)
-      expect(results).not_to include(reply)
-    end
-
-    it 'does not include boosts' do
-      status = Fabricate(:status)
-      boost = Fabricate(:status, reblog_of_id: status.id)
-
-      results = Status.as_public_timeline
-      expect(results).to include(status)
-      expect(results).not_to include(boost)
-    end
-
-    it 'filters out silenced accounts' do
-      account = Fabricate(:account)
-      silenced_account = Fabricate(:account, silenced: true)
-      status = Fabricate(:status, account: account)
-      silenced_status = Fabricate(:status, account: silenced_account)
-
-      results = Status.as_public_timeline
-      expect(results).to include(status)
-      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
-      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
-
-    context 'with a remote_only option set' do
-      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, :remote) }
-
-      context 'without a viewer' do
-        let(:viewer) { nil }
-
-        it 'does not include local instances statuses' do
-          expect(subject).not_to include(local_status)
-          expect(subject).to include(remote_status)
-        end
-      end
-
-      context 'with a viewer' do
-        let(:viewer) { Fabricate(:account, username: 'viewer') }
-
-        it 'does not include local instances statuses' do
-          expect(subject).not_to include(local_status)
-          expect(subject).to include(remote_status)
-        end
-      end
-    end
-
-    describe 'with an account passed in' do
-      before do
-        @account = Fabricate(:account)
-      end
-
-      it 'excludes statuses from accounts blocked by the account' do
-        blocked = Fabricate(:account)
-        Fabricate(:block, account: @account, target_account: blocked)
-        blocked_status = Fabricate(:status, account: blocked)
-
-        results = Status.as_public_timeline(@account)
-        expect(results).not_to include(blocked_status)
-      end
-
-      it 'excludes statuses from accounts who have blocked the account' do
-        blocked = Fabricate(:account)
-        Fabricate(:block, account: blocked, target_account: @account)
-        blocked_status = Fabricate(:status, account: blocked)
-
-        results = Status.as_public_timeline(@account)
-        expect(results).not_to include(blocked_status)
-      end
-
-      it 'excludes statuses from accounts muted by the account' do
-        muted = Fabricate(:account)
-        Fabricate(:mute, account: @account, target_account: muted)
-        muted_status = Fabricate(:status, account: muted)
-
-        results = Status.as_public_timeline(@account)
-        expect(results).not_to include(muted_status)
-      end
-
-      it 'excludes statuses from accounts from personally blocked domains' do
-        blocked = Fabricate(:account, domain: 'example.com')
-        @account.block_domain!(blocked.domain)
-        blocked_status = Fabricate(:status, account: blocked)
-
-        results = Status.as_public_timeline(@account)
-        expect(results).not_to include(blocked_status)
-      end
-
-      context 'with language preferences' do
-        it 'excludes statuses in languages not allowed by the account user' do
-          user = Fabricate(:user, chosen_languages: [:en, :es])
-          @account.update(user: user)
-          en_status = Fabricate(:status, language: 'en')
-          es_status = Fabricate(:status, language: 'es')
-          fr_status = Fabricate(:status, language: 'fr')
-
-          results = Status.as_public_timeline(@account)
-          expect(results).to include(en_status)
-          expect(results).to include(es_status)
-          expect(results).not_to include(fr_status)
-        end
-
-        it 'includes all languages when user does not have a setting' do
-          user = Fabricate(:user, chosen_languages: nil)
-          @account.update(user: user)
-
-          en_status = Fabricate(:status, language: 'en')
-          es_status = Fabricate(:status, language: 'es')
-
-          results = Status.as_public_timeline(@account)
-          expect(results).to include(en_status)
-          expect(results).to include(es_status)
-        end
-
-        it 'includes all languages when account does not have a user' do
-          expect(@account.user).to be_nil
-          en_status = Fabricate(:status, language: 'en')
-          es_status = Fabricate(:status, language: 'es')
-
-          results = Status.as_public_timeline(@account)
-          expect(results).to include(en_status)
-          expect(results).to include(es_status)
-        end
-      end
-    end
-
-    context 'with local-only statuses' do
-      let(:status) { Fabricate(:status, local_only: true) }
-
-      subject { Status.as_public_timeline(viewer) }
-
-      context 'without a viewer' do
-        let(:viewer) { nil }
-
-        it 'excludes local-only statuses' do
-          expect(subject).to_not include(status)
-        end
-      end
-
-      context 'with a viewer' do
-        let(:viewer) { Fabricate(:account, username: 'viewer') }
-
-        it 'includes local-only statuses' do
-          expect(subject).to include(status)
-        end
-      end
-
-      # TODO: What happens if the viewer is remote?
-      # Can the viewer be remote?
-      # What prevents the viewer from being remote?
-    end
-  end
-
-  describe '.as_tag_timeline' do
-    it 'includes statuses with a tag' do
-      tag = Fabricate(:tag)
-      status = Fabricate(:status, tags: [tag])
-      other = Fabricate(:status)
-
-      results = Status.as_tag_timeline(tag)
-      expect(results).to include(status)
-      expect(results).not_to include(other)
-    end
-
-    it 'allows replies to be included' do
-      original = Fabricate(:status)
-      tag = Fabricate(:tag)
-      status = Fabricate(:status, tags: [tag], in_reply_to_id: original.id)
-
-      results = Status.as_tag_timeline(tag)
-      expect(results).to include(status)
-    end
-
-    context 'on a local-only status' do
-      let(:tag) { Fabricate(:tag) }
-      let(:status) { Fabricate(:status, local_only: true, tags: [tag]) }
-
-      context 'without a viewer' do
-        let(:viewer) { nil }
-
-        it 'filters the local-only status out of the result set' do
-          expect(Status.as_tag_timeline(tag, viewer)).not_to include(status)
-        end
-      end
-
-      context 'with a viewer' do
-        let(:viewer) { Fabricate(:account, username: 'viewer', domain: nil) }
-
-        it 'keeps the local-only status in the result set' do
-          expect(Status.as_tag_timeline(tag, viewer)).to include(status)
-        end
-      end
-    end
-  end
-
   describe '.permitted_for' do
     subject { described_class.permitted_for(target_account, account).pluck(:visibility) }
 
diff --git a/spec/services/hashtag_query_service_spec.rb b/spec/models/tag_feed_spec.rb
index 24282d2f0..76277c467 100644
--- a/spec/services/hashtag_query_service_spec.rb
+++ b/spec/models/tag_feed_spec.rb
@@ -1,7 +1,7 @@
 require 'rails_helper'
 
-describe HashtagQueryService, type: :service do
-  describe '.call' do
+describe TagFeed, type: :service do
+  describe '#get' do
     let(:account) { Fabricate(:account) }
     let(:tag1) { Fabricate(:tag) }
     let(:tag2) { Fabricate(:tag) }
@@ -10,35 +10,35 @@ describe HashtagQueryService, type: :service do
     let!(:both) { Fabricate(:status, tags: [tag1, tag2]) }
 
     it 'can add tags in "any" mode' do
-      results = subject.call(tag1, { any: [tag2.name] })
+      results = described_class.new(tag1, nil, any: [tag2.name]).get(20)
       expect(results).to include status1
       expect(results).to include status2
       expect(results).to include both
     end
 
     it 'can remove tags in "all" mode' do
-      results = subject.call(tag1, { all: [tag2.name] })
+      results = described_class.new(tag1, nil, all: [tag2.name]).get(20)
       expect(results).to_not include status1
       expect(results).to_not include status2
       expect(results).to     include both
     end
 
     it 'can remove tags in "none" mode' do
-      results = subject.call(tag1, { none: [tag2.name] })
+      results = described_class.new(tag1, nil, none: [tag2.name]).get(20)
       expect(results).to     include status1
       expect(results).to_not include status2
       expect(results).to_not include both
     end
 
     it 'ignores an invalid mode' do
-      results = subject.call(tag1, { wark: [tag2.name] })
+      results = described_class.new(tag1, nil, wark: [tag2.name]).get(20)
       expect(results).to     include status1
       expect(results).to_not include status2
       expect(results).to     include both
     end
 
     it 'handles being passed non existant tag names' do
-      results = subject.call(tag1, { any: ['wark'] })
+      results = described_class.new(tag1, nil, any: ['wark']).get(20)
       expect(results).to     include status1
       expect(results).to_not include status2
       expect(results).to     include both
@@ -46,15 +46,37 @@ describe HashtagQueryService, type: :service do
 
     it 'can restrict to an account' do
       BlockService.new.call(account, status1.account)
-      results = subject.call(tag1, { none: [tag2.name] }, account)
+      results = described_class.new(tag1, account, none: [tag2.name]).get(20)
       expect(results).to_not include status1
     end
 
     it 'can restrict to local' do
       status1.account.update(domain: 'example.com')
       status1.update(local: false, uri: 'example.com/toot')
-      results = subject.call(tag1, { any: [tag2.name] }, nil, true)
+      results = described_class.new(tag1, nil, any: [tag2.name], local: true).get(20)
       expect(results).to_not include status1
     end
+
+    it 'allows replies to be included' do
+      original = Fabricate(:status)
+      status = Fabricate(:status, tags: [tag1], in_reply_to_id: original.id)
+
+      results = described_class.new(tag1, nil).get(20)
+      expect(results).to include(status)
+    end
+
+    context 'on a local-only status' do
+      let!(:status) { Fabricate(:status, tags: [tag1], local_only: true) }
+
+      it 'does not show local-only statuses without a viewer' do
+        results = described_class.new(tag1, nil).get(20)
+        expect(results).to_not include(status)
+      end
+
+      it 'shows local-only statuses given a viewer' do
+        results = described_class.new(tag1, account).get(20)
+        expect(results).to include(status)
+      end
+    end
   end
 end
diff --git a/spec/services/fan_out_on_write_service_spec.rb b/spec/services/fan_out_on_write_service_spec.rb
index b7fc7f7ed..538dc2592 100644
--- a/spec/services/fan_out_on_write_service_spec.rb
+++ b/spec/services/fan_out_on_write_service_spec.rb
@@ -28,10 +28,10 @@ RSpec.describe FanOutOnWriteService, type: :service do
   end
 
   it 'delivers status to hashtag' do
-    expect(Tag.find_by!(name: 'test').statuses.pluck(:id)).to include status.id
+    expect(TagFeed.new(Tag.find_by(name: 'test'), alice).get(20).map(&:id)).to include status.id
   end
 
   it 'delivers status to public timeline' do
-    expect(Status.as_public_timeline(alice).map(&:id)).to include status.id
+    expect(PublicFeed.new(alice).get(20).map(&:id)).to include status.id
   end
 end