fix(article): enforce maximum length for content validation (#109)
* fix(article): enforce maximum length for content validation * fix(article): update content length validation to allow up to 65535 characters
This commit is contained in:
parent
0b6d943faf
commit
3dac94e058
@ -58,7 +58,7 @@ class Article < ApplicationRecord
|
|||||||
validates :account_id, presence: true
|
validates :account_id, presence: true
|
||||||
validates :author_id, presence: true
|
validates :author_id, presence: true
|
||||||
validates :title, presence: true
|
validates :title, presence: true
|
||||||
validates :content, presence: true
|
validates :content, presence: true, length: { maximum: 65_535 }
|
||||||
|
|
||||||
# ensuring that the position is always set correctly
|
# ensuring that the position is always set correctly
|
||||||
before_create :add_position_to_article
|
before_create :add_position_to_article
|
||||||
|
|||||||
@ -33,9 +33,9 @@ RSpec.describe Article do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it 'invalid when crossed the limit' do
|
it 'invalid when crossed the limit' do
|
||||||
article.content = 'a' * 25_001
|
article.content = 'a' * 70_000
|
||||||
article.valid?
|
article.valid?
|
||||||
expect(article.errors[:content]).to include('is too long (maximum is 20000 characters)')
|
expect(article.errors[:content]).to include('is too long (maximum is 65535 characters)')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user