From 0a7cff53c2577b3e79599e069eeb344f2613ad8d Mon Sep 17 00:00:00 2001
From: Matt Jankowski <matt@jankowski.online>
Date: Thu, 11 Jan 2024 04:30:29 -0500
Subject: [PATCH] Add coverage for `Account.followable_by` scope (#28689)

---
 spec/models/account_spec.rb | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/spec/models/account_spec.rb b/spec/models/account_spec.rb
index 87aa8bc754..b4fcb805a6 100644
--- a/spec/models/account_spec.rb
+++ b/spec/models/account_spec.rb
@@ -1009,4 +1009,27 @@ RSpec.describe Account do
       expect(subject.reload.followers_count).to eq 15
     end
   end
+
+  describe '.followable_by' do
+    context 'with follows and follow requests' do
+      let!(:account) { Fabricate(:account) }
+      let!(:eligible_account) { Fabricate(:account) }
+      let!(:following_account) { Fabricate(:account) }
+      let!(:follow_requested_account) { Fabricate(:account) }
+
+      before do
+        Fabricate :follow, account: account, target_account: following_account
+        Fabricate :follow_request, account: account, target_account: follow_requested_account
+      end
+
+      it 'returns accounts not already following or requested to follow' do
+        results = described_class.followable_by(account)
+
+        expect(results)
+          .to include(eligible_account)
+          .and not_include(following_account)
+          .and not_include(follow_requested_account)
+      end
+    end
+  end
 end