Use validation matchers for InstanceModerationNote spec (#37597)
This commit is contained in:
parent
2edcb234e0
commit
f7a2e5c715
@ -14,24 +14,12 @@ RSpec.describe InstanceModerationNote do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'validations' do
|
describe 'Validations' do
|
||||||
it 'is invalid if the content is empty' do
|
subject { Fabricate.build :instance_moderation_note }
|
||||||
note = Fabricate.build(:instance_moderation_note, domain: 'mastodon.example', content: '')
|
|
||||||
expect(note.valid?).to be false
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'is invalid if content is longer than character limit' do
|
it { is_expected.to allow_value('non-existent.example').for(:domain) }
|
||||||
note = Fabricate.build(:instance_moderation_note, domain: 'mastodon.example', content: comment_over_limit)
|
it { is_expected.to validate_length_of(:content).is_at_most(described_class::CONTENT_SIZE_LIMIT) }
|
||||||
expect(note.valid?).to be false
|
it { is_expected.to validate_presence_of(:content) }
|
||||||
end
|
it { is_expected.to validate_presence_of(:domain) }
|
||||||
|
|
||||||
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
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user