0
0
Fork 0

Add validation coverage for CustomEmoji shortcode value (#31906)

This commit is contained in:
Matt Jankowski 2024-09-16 03:53:03 -04:00 committed by GitHub
parent 822e918a56
commit abd2f5654a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 11 additions and 1 deletions

View file

@ -84,4 +84,13 @@ RSpec.describe CustomEmoji, :attachment_processing do
it { is_expected.to normalize(:domain).from(nil).to(nil) }
end
end
describe 'Validations' do
subject { Fabricate.build :custom_emoji }
it { is_expected.to validate_uniqueness_of(:shortcode).scoped_to(:domain) }
it { is_expected.to validate_length_of(:shortcode).is_at_least(described_class::MINIMUM_SHORTCODE_SIZE) }
it { is_expected.to allow_values('cats').for(:shortcode) }
it { is_expected.to_not allow_values('@#$@#$', 'X').for(:shortcode) }
end
end