mirror of
https://github.com/mastodon/mastodon.git
synced 2026-04-24 15:18:46 -05:00
Remove description presence validation on collections (#38528)
This commit is contained in:
parent
145dcfadce
commit
814cd61fd8
|
|
@ -36,11 +36,9 @@ class Collection < ApplicationRecord
|
|||
validates :name, length: { maximum: 40 }, if: :local?
|
||||
validates :name, length: { maximum: NAME_LENGTH_HARD_LIMIT }, if: :remote?
|
||||
validates :description,
|
||||
presence: true,
|
||||
length: { maximum: 100 },
|
||||
if: :local?
|
||||
validates :description_html,
|
||||
presence: true,
|
||||
length: { maximum: DESCRIPTION_LENGTH_HARD_LIMIT },
|
||||
if: :remote?
|
||||
validates :local, inclusion: [true, false]
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ class REST::CollectionSerializer < ActiveModel::Serializer
|
|||
|
||||
def description
|
||||
return object.description if object.local?
|
||||
return if object.description_html.nil?
|
||||
|
||||
Sanitize.fragment(object.description_html, Sanitize::Config::MASTODON_STRICT)
|
||||
end
|
||||
|
|
|
|||
|
|
@ -10,8 +10,6 @@ RSpec.describe Collection do
|
|||
|
||||
it { is_expected.to validate_length_of(:name).is_at_most(40) }
|
||||
|
||||
it { is_expected.to validate_presence_of(:description) }
|
||||
|
||||
it { is_expected.to validate_length_of(:description).is_at_most(100) }
|
||||
|
||||
it { is_expected.to_not allow_value(nil).for(:local) }
|
||||
|
|
@ -29,10 +27,6 @@ RSpec.describe Collection do
|
|||
|
||||
it { is_expected.to validate_length_of(:name).is_at_most(Collection::NAME_LENGTH_HARD_LIMIT) }
|
||||
|
||||
it { is_expected.to_not validate_presence_of(:description) }
|
||||
|
||||
it { is_expected.to validate_presence_of(:description_html) }
|
||||
|
||||
it { is_expected.to validate_length_of(:description_html).is_at_most(Collection::DESCRIPTION_LENGTH_HARD_LIMIT) }
|
||||
|
||||
it { is_expected.to validate_presence_of(:uri) }
|
||||
|
|
|
|||
|
|
@ -180,7 +180,6 @@ RSpec.describe 'Api::V1Alpha::Collections', feature: :collections do
|
|||
'error' => a_hash_including({
|
||||
'details' => a_hash_including({
|
||||
'name' => [{ 'error' => 'ERR_BLANK', 'description' => "can't be blank" }],
|
||||
'description' => [{ 'error' => 'ERR_BLANK', 'description' => "can't be blank" }],
|
||||
}),
|
||||
}),
|
||||
})
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user