From ff490daa5801a0d5b8c78480faa17ae5a7f5b2f1 Mon Sep 17 00:00:00 2001
From: Matt Jankowski <matt@jankowski.online>
Date: Mon, 4 Nov 2024 04:00:01 -0500
Subject: [PATCH] Reduce factory generation in `AccountStatusesFilter` spec
 (#32727)

---
 spec/lib/account_statuses_filter_spec.rb | 42 +++++++++---------------
 1 file changed, 15 insertions(+), 27 deletions(-)

diff --git a/spec/lib/account_statuses_filter_spec.rb b/spec/lib/account_statuses_filter_spec.rb
index 777458512..351d3dae5 100644
--- a/spec/lib/account_statuses_filter_spec.rb
+++ b/spec/lib/account_statuses_filter_spec.rb
@@ -52,36 +52,24 @@ RSpec.describe AccountStatusesFilter do
     end
 
     shared_examples 'filter params' do
-      context 'with only_media param' do
-        let(:params) { { only_media: true } }
+      it 'respects param options in results' do
+        expect(results_for(only_media: true))
+          .to all(satisfy(&:with_media?))
 
-        it 'returns only statuses with media' do
-          expect(subject.all?(&:with_media?)).to be true
-        end
+        expect(results_for(tagged: tag.name))
+          .to all(satisfy { |status| status.tags.include?(tag) })
+
+        expect(results_for(exclude_replies: true))
+          .to all(satisfy { |status| !status.reply? })
+
+        expect(results_for(exclude_reblogs: true))
+          .to all(satisfy { |status| !status.reblog? })
       end
 
-      context 'with tagged param' do
-        let(:params) { { tagged: tag.name } }
-
-        it 'returns only statuses with tag' do
-          expect(subject.all? { |s| s.tags.include?(tag) }).to be true
-        end
-      end
-
-      context 'with exclude_replies param' do
-        let(:params) { { exclude_replies: true } }
-
-        it 'returns only statuses that are not replies' do
-          expect(subject.none?(&:reply?)).to be true
-        end
-      end
-
-      context 'with exclude_reblogs param' do
-        let(:params) { { exclude_reblogs: true } }
-
-        it 'returns only statuses that are not reblogs' do
-          expect(subject.none?(&:reblog?)).to be true
-        end
+      def results_for(params)
+        described_class
+          .new(account, current_account, params)
+          .results
       end
     end