about summary refs log tree commit diff
path: root/spec/validators/status_length_validator_spec.rb
diff options
context:
space:
mode:
authorClaire <claire.github-309c@sitedethib.com>2022-03-30 15:02:56 +0200
committerClaire <claire.github-309c@sitedethib.com>2022-03-30 15:02:56 +0200
commitfc5dd0c538a8cf33d007a01e168b3bfc0cdc9060 (patch)
tree2b8b804b5fd0265f57ae87f3b0315c6c8d14c9ef /spec/validators/status_length_validator_spec.rb
parent60f9973f452100475874cd9bd0a8b6ee908bf8e0 (diff)
parent8c7223f4eac80b5725485be742d3fa2c984f4670 (diff)
Merge branch 'main' into glitch-soc/merge-upstream
Diffstat (limited to 'spec/validators/status_length_validator_spec.rb')
-rw-r--r--spec/validators/status_length_validator_spec.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/spec/validators/status_length_validator_spec.rb b/spec/validators/status_length_validator_spec.rb
index 643ea6d22..4c80a59e6 100644
--- a/spec/validators/status_length_validator_spec.rb
+++ b/spec/validators/status_length_validator_spec.rb
@@ -55,6 +55,13 @@ describe StatusLengthValidator do
       expect(status.errors).to have_received(:add)
     end
 
+    it 'does not count overly long URLs as 23 characters flat' do
+      text = "http://example.com/valid?#{'#foo?' * 1000}"
+      status = double(spoiler_text: '', text: text, errors: double(add: nil), local?: true, reblog?: false)
+      subject.validate(status)
+      expect(status.errors).to have_received(:add)
+    end
+
     it 'counts only the front part of remote usernames' do
       username = '@alice'
       chars = StatusLengthValidator::MAX_CHARS - 1 - username.length
@@ -64,5 +71,13 @@ describe StatusLengthValidator do
       subject.validate(status)
       expect(status.errors).to_not have_received(:add)
     end
+
+    it 'does count both parts of remote usernames for overly long domains' do
+      text   = "@alice@#{'b' * 500}.com"
+      status = double(spoiler_text: '', text: text, errors: double(add: nil), local?: true, reblog?: false)
+
+      subject.validate(status)
+      expect(status.errors).to have_received(:add)
+    end
   end
 end