Allow reports with long comments from remote instances, but truncate (#25028)

This commit is contained in:
Emelia Smith
2023-05-22 13:15:21 +02:00
committed by GitHub
parent d51464283c
commit 19f9098551
6 changed files with 62 additions and 11 deletions

View File

@@ -121,10 +121,17 @@ describe Report do
end
describe 'validations' do
it 'is invalid if comment is longer than 1000 characters' do
let(:remote_account) { Fabricate(:account, domain: 'example.com', protocol: :activitypub, inbox_url: 'http://example.com/inbox') }
it 'is invalid if comment is longer than 1000 characters only if reporter is local' do
report = Fabricate.build(:report, comment: Faker::Lorem.characters(number: 1001))
report.valid?
expect(report.valid?).to be false
expect(report).to model_have_error_on_field(:comment)
end
it 'is valid if comment is longer than 1000 characters and reporter is not local' do
report = Fabricate.build(:report, account: remote_account, comment: Faker::Lorem.characters(number: 1001))
expect(report.valid?).to be true
end
end
end