From f7a2e5c715228a0ab68dfe927a39f87ee9c94796 Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Mon, 26 Jan 2026 04:42:55 -0500 Subject: [PATCH] Use validation matchers for InstanceModerationNote spec (#37597) --- spec/models/instance_moderation_note_spec.rb | 24 +++++--------------- 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/spec/models/instance_moderation_note_spec.rb b/spec/models/instance_moderation_note_spec.rb index 011b001cc7..23e6e3d5e1 100644 --- a/spec/models/instance_moderation_note_spec.rb +++ b/spec/models/instance_moderation_note_spec.rb @@ -14,24 +14,12 @@ RSpec.describe InstanceModerationNote do end end - describe 'validations' do - it 'is invalid if the content is empty' do - note = Fabricate.build(:instance_moderation_note, domain: 'mastodon.example', content: '') - expect(note.valid?).to be false - end + describe 'Validations' do + subject { Fabricate.build :instance_moderation_note } - it 'is invalid if content is longer than character limit' do - note = Fabricate.build(:instance_moderation_note, domain: 'mastodon.example', content: comment_over_limit) - expect(note.valid?).to be false - end - - it 'is valid even if the instance does not exist yet' do - note = Fabricate.build(:instance_moderation_note, domain: 'non-existent.example', content: 'test comment') - expect(note.valid?).to be true - end - - def comment_over_limit - Faker::Lorem.paragraph_by_chars(number: described_class::CONTENT_SIZE_LIMIT * 2) - end + it { is_expected.to allow_value('non-existent.example').for(:domain) } + it { is_expected.to validate_length_of(:content).is_at_most(described_class::CONTENT_SIZE_LIMIT) } + it { is_expected.to validate_presence_of(:content) } + it { is_expected.to validate_presence_of(:domain) } end end