DEV: add maxlength to additional chat text columns (#23505)
Add additional limits to text columns for chat.
This commit is contained in:
parent
f25849501d
commit
6e672557fa
|
@ -37,6 +37,8 @@ module Chat
|
|||
presence: true,
|
||||
allow_nil: true
|
||||
validates :description, length: { maximum: 500 }
|
||||
validates :chatable_type, length: { maximum: 100 }
|
||||
validates :type, length: { maximum: 100 }
|
||||
validates :slug, length: { maximum: 100 }
|
||||
validate :ensure_slug_ok, if: :slug_changed?
|
||||
before_validation :generate_auto_slug
|
||||
|
|
|
@ -6,6 +6,9 @@ module Chat
|
|||
belongs_to :archived_by, class_name: "User"
|
||||
belongs_to :destination_topic, class_name: "Topic"
|
||||
|
||||
validates :archive_error, length: { maximum: 1000 }
|
||||
validates :destination_topic_title, length: { maximum: 1000 }
|
||||
|
||||
self.table_name = "chat_channel_archives"
|
||||
|
||||
def complete?
|
||||
|
|
|
@ -12,6 +12,12 @@ module Chat
|
|||
|
||||
before_create { self.key = SecureRandom.hex(12) }
|
||||
|
||||
validates :name, presence: true, length: { maximum: 100 }
|
||||
validates :key, length: { maximum: 100 }
|
||||
validates :username, length: { maximum: 100 }
|
||||
validates :description, length: { maximum: 500 }
|
||||
validates :emoji, length: { maximum: 100 }
|
||||
|
||||
def url
|
||||
"#{Discourse.base_url}/chat/hooks/#{key}.json"
|
||||
end
|
||||
|
|
|
@ -6,6 +6,8 @@ module Chat
|
|||
|
||||
belongs_to :chat_message, class_name: "Chat::Message"
|
||||
belongs_to :user
|
||||
|
||||
validates :emoji, length: { maximum: 100 }
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -2,6 +2,9 @@
|
|||
|
||||
module Chat
|
||||
class ReviewableMessage < Reviewable
|
||||
validates :type, length: { maximum: 100 }
|
||||
validates :target_type, length: { maximum: 100 }
|
||||
|
||||
def serializer
|
||||
Chat::ReviewableMessageSerializer
|
||||
end
|
||||
|
|
|
@ -9,6 +9,8 @@ RSpec.describe Chat::CategoryChannel do
|
|||
it { is_expected.to delegate_method(:url).to(:chatable).with_prefix }
|
||||
it { is_expected.to validate_length_of(:description).is_at_most(500) }
|
||||
it { is_expected.to validate_length_of(:slug).is_at_most(100) }
|
||||
it { is_expected.to validate_length_of(:chatable_type).is_at_most(100) }
|
||||
it { is_expected.to validate_length_of(:type).is_at_most(100) }
|
||||
|
||||
describe "#category_channel?" do
|
||||
it "always returns true" do
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
RSpec.describe Chat::ChannelArchive do
|
||||
it { is_expected.to validate_length_of(:archive_error).is_at_most(1000) }
|
||||
it { is_expected.to validate_length_of(:destination_topic_title).is_at_most(1000) }
|
||||
end
|
|
@ -8,6 +8,8 @@ RSpec.describe Chat::Channel do
|
|||
|
||||
it { is_expected.to validate_length_of(:description).is_at_most(500) }
|
||||
it { is_expected.to validate_length_of(:slug).is_at_most(100) }
|
||||
it { is_expected.to validate_length_of(:chatable_type).is_at_most(100) }
|
||||
it { is_expected.to validate_length_of(:type).is_at_most(100) }
|
||||
|
||||
describe ".find_by_id_or_slug" do
|
||||
subject(:find_channel) { described_class.find_by_id_or_slug(channel_id) }
|
||||
|
|
|
@ -7,6 +7,8 @@ RSpec.describe Chat::DirectMessageChannel do
|
|||
|
||||
it { is_expected.to delegate_method(:allowed_user_ids).to(:direct_message).as(:user_ids) }
|
||||
it { is_expected.to validate_length_of(:description).is_at_most(500) }
|
||||
it { is_expected.to validate_length_of(:chatable_type).is_at_most(100) }
|
||||
it { is_expected.to validate_length_of(:type).is_at_most(100) }
|
||||
|
||||
describe "#category_channel?" do
|
||||
it "always returns false" do
|
||||
|
|
|
@ -7,4 +7,10 @@ RSpec.describe Chat::IncomingWebhook do
|
|||
.class_name("Chat::WebhookEvent")
|
||||
.dependent(:delete_all)
|
||||
end
|
||||
|
||||
it { is_expected.to validate_length_of(:name).is_at_most(100) }
|
||||
it { is_expected.to validate_length_of(:key).is_at_most(100) }
|
||||
it { is_expected.to validate_length_of(:username).is_at_most(100) }
|
||||
it { is_expected.to validate_length_of(:description).is_at_most(500) }
|
||||
it { is_expected.to validate_length_of(:emoji).is_at_most(100) }
|
||||
end
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
RSpec.describe Chat::MessageReaction do
|
||||
it { is_expected.to validate_length_of(:emoji).is_at_most(100) }
|
||||
end
|
|
@ -11,6 +11,9 @@ RSpec.describe Chat::ReviewableMessage, type: :model do
|
|||
Fabricate(:chat_reviewable_message, target: chat_message, created_by: moderator)
|
||||
end
|
||||
|
||||
it { is_expected.to validate_length_of(:type).is_at_most(100) }
|
||||
it { is_expected.to validate_length_of(:target_type).is_at_most(100) }
|
||||
|
||||
it "agree_and_keep agrees with the flag and doesn't delete the message" do
|
||||
reviewable.perform(moderator, :agree_and_keep_message)
|
||||
|
||||
|
|
Loading…
Reference in New Issue