DEV: Set limits on custom fields

This patch sets some limits on custom fields:
- an entity can’t have more than 100 custom fields defined on it
- a custom field can’t hold a value greater than 10,000,000 characters

The current implementation of custom fields is relatively complex and
does an upsert in SQL at some point, thus preventing to simply add an
`ActiveRecord` validation on the custom field model without having to
rewrite a part of the existing logic.
That’s one of the reasons this patch is implementing validations in the
`HasCustomField` module adding them to the model including the module.
This commit is contained in:
Loïc Guitaut
2023-06-05 17:38:50 +02:00
committed by Loïc Guitaut
parent c08a52e502
commit 5257c80064
8 changed files with 74 additions and 4 deletions

View File

@ -1,9 +1,11 @@
# frozen_string_literal: true
RSpec.describe User do
subject(:user) { Fabricate(:user, last_seen_at: 1.day.ago) }
fab!(:group) { Fabricate(:group) }
subject(:user) { Fabricate(:user, last_seen_at: 1.day.ago) }
it_behaves_like "it has custom fields"
def user_error_message(*keys)
I18n.t(:"activerecord.errors.models.user.attributes.#{keys.join(".")}")