about summary refs log tree commit diff
path: root/spec/models/follow_spec.rb
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2018-10-04 17:36:11 +0200
committerGitHub <noreply@github.com>2018-10-04 17:36:11 +0200
commita46ab86adfc9e4ea182af9a555237f17071e194c (patch)
treeed5d073badf675fdc0661c54467cc52de85c90b2 /spec/models/follow_spec.rb
parent186024a058d4b8765a10d87ff3d7f3bdcd2fbb3c (diff)
Limit the number of people that can be followed from one account (#8807)
Configurable soft limit of 7,500, and above that, configurable
ratio of 1.1 * followers, controlled by:

- MAX_FOLLOWS_THRESHOLD
- MAX_FOLLOWS_RATIO

Fix #2311
Diffstat (limited to 'spec/models/follow_spec.rb')
-rw-r--r--spec/models/follow_spec.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/spec/models/follow_spec.rb b/spec/models/follow_spec.rb
index f221973b6..0c84e5e7b 100644
--- a/spec/models/follow_spec.rb
+++ b/spec/models/follow_spec.rb
@@ -23,6 +23,20 @@ RSpec.describe Follow, type: :model do
       follow.valid?
       expect(follow).to model_have_error_on_field(:target_account)
     end
+
+    it 'is invalid if account already follows too many people' do
+      alice.update(following_count: FollowLimitValidator::LIMIT)
+
+      expect(subject).to_not be_valid
+      expect(subject).to model_have_error_on_field(:base)
+    end
+
+    it 'is valid if account is only on the brink of following too many people' do
+      alice.update(following_count: FollowLimitValidator::LIMIT - 1)
+
+      expect(subject).to be_valid
+      expect(subject).to_not model_have_error_on_field(:base)
+    end
   end
 
   describe 'recent' do