diff --git a/app/models/collection.rb b/app/models/collection.rb index 3be633bbf1..c8d4fb99bc 100644 --- a/app/models/collection.rb +++ b/app/models/collection.rb @@ -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] diff --git a/app/serializers/rest/collection_serializer.rb b/app/serializers/rest/collection_serializer.rb index c3f2b55a84..c668ec37dc 100644 --- a/app/serializers/rest/collection_serializer.rb +++ b/app/serializers/rest/collection_serializer.rb @@ -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 diff --git a/spec/models/collection_spec.rb b/spec/models/collection_spec.rb index 6937829ebb..64e93b6797 100644 --- a/spec/models/collection_spec.rb +++ b/spec/models/collection_spec.rb @@ -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) } diff --git a/spec/requests/api/v1_alpha/collections_spec.rb b/spec/requests/api/v1_alpha/collections_spec.rb index a0573342d8..f448659bf5 100644 --- a/spec/requests/api/v1_alpha/collections_spec.rb +++ b/spec/requests/api/v1_alpha/collections_spec.rb @@ -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" }], }), }), })