From 3cac5bc2c3105ab0daab1e6892348d5be96d66a3 Mon Sep 17 00:00:00 2001 From: Surinna Curtis Date: Sun, 10 Sep 2017 19:43:52 -0500 Subject: [PATCH] Fix a spuriously failing spec that assumed we required short bios like upstream --- app/models/account.rb | 4 +++- .../api/v1/accounts/credentials_controller_spec.rb | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/models/account.rb b/app/models/account.rb index d0ebf5a5e0..ac27c7923f 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -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 diff --git a/spec/controllers/api/v1/accounts/credentials_controller_spec.rb b/spec/controllers/api/v1/accounts/credentials_controller_spec.rb index 461b8b34bb..247420d083 100644 --- a/spec/controllers/api/v1/accounts/credentials_controller_spec.rb +++ b/spec/controllers/api/v1/accounts/credentials_controller_spec.rb @@ -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