]> cat aescling's git repositories - mastodon.git/commitdiff
Fix a spuriously failing spec that assumed we required short bios like upstream
authorSurinna Curtis <ekiru.0@gmail.com>
Mon, 11 Sep 2017 00:43:52 +0000 (19:43 -0500)
committerSurinna Curtis <ekiru.0@gmail.com>
Mon, 11 Sep 2017 00:43:52 +0000 (19:43 -0500)
app/models/account.rb
spec/controllers/api/v1/accounts/credentials_controller_spec.rb

index d0ebf5a5e00a8d4a3b3424f9d2cc250a8a2ad07e..ac27c7923ff5dfdf6d4c15026f831a8509eb18fb 100644 (file)
@@ -54,6 +54,8 @@ class Account < ApplicationRecord
   include Remotable
   include EmojiHelper
 
+  MAX_NOTE_LENGTH = 500
+
   enum protocol: [:ostatus, :activitypub]
 
   # Local users
@@ -288,7 +290,7 @@ class Account < ApplicationRecord
         note_without_metadata = note[(idx + YAML_END.length) .. -1]
       end
     end
-    if note_without_metadata.mb_chars.grapheme_length > 500
+    if note_without_metadata.mb_chars.grapheme_length > MAX_NOTE_LENGTH
       errors.add(:note, "can't be longer than 500 graphemes")
     end
   end
index 461b8b34bb6dadf68a139314149f9743938aec1b..247420d08328268e555dc7d8973cda51933b27be 100644 (file)
@@ -51,7 +51,9 @@ describe Api::V1::Accounts::CredentialsController do
 
       describe 'with invalid data' do
         before do
-          patch :update, params: { note: 'This is too long. ' * 10 }
+          note = 'This is too long. '
+          note = note + 'a' * (Account::MAX_NOTE_LENGTH - note.length + 1)
+          patch :update, params: { note: note }
         end
 
         it 'returns http unprocessable entity' do
This page took 0.025208 seconds and 3 git commands to generate.