mirror of
https://git.kescher.at/CatCatNya/catstodon.git
synced 2024-11-26 00:51:37 +01:00
Extract COMMENT_SIZE_LIMIT
constant in AP::Activity::Flag
class (#30637)
This commit is contained in:
parent
9bf2e2eda0
commit
9cc4040308
2 changed files with 10 additions and 6 deletions
|
@ -1,6 +1,8 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class ActivityPub::Activity::Flag < ActivityPub::Activity
|
class ActivityPub::Activity::Flag < ActivityPub::Activity
|
||||||
|
COMMENT_SIZE_LIMIT = 5000
|
||||||
|
|
||||||
def perform
|
def perform
|
||||||
return if skip_reports?
|
return if skip_reports?
|
||||||
|
|
||||||
|
@ -38,6 +40,6 @@ class ActivityPub::Activity::Flag < ActivityPub::Activity
|
||||||
end
|
end
|
||||||
|
|
||||||
def report_comment
|
def report_comment
|
||||||
(@json['content'] || '')[0...5000]
|
(@json['content'] || '')[0...COMMENT_SIZE_LIMIT]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -54,7 +54,7 @@ RSpec.describe ActivityPub::Activity::Flag do
|
||||||
}.with_indifferent_access, sender)
|
}.with_indifferent_access, sender)
|
||||||
end
|
end
|
||||||
|
|
||||||
let(:long_comment) { Faker::Lorem.characters(number: 6000) }
|
let(:long_comment) { 'a' * described_class::COMMENT_SIZE_LIMIT * 2 }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
subject.perform
|
subject.perform
|
||||||
|
@ -63,10 +63,12 @@ RSpec.describe ActivityPub::Activity::Flag do
|
||||||
it 'creates a report but with a truncated comment' do
|
it 'creates a report but with a truncated comment' do
|
||||||
report = Report.find_by(account: sender, target_account: flagged)
|
report = Report.find_by(account: sender, target_account: flagged)
|
||||||
|
|
||||||
expect(report).to_not be_nil
|
expect(report)
|
||||||
expect(report.comment.length).to eq 5000
|
.to be_present
|
||||||
expect(report.comment).to eq long_comment[0...5000]
|
.and have_attributes(status_ids: [status.id])
|
||||||
expect(report.status_ids).to eq [status.id]
|
expect(report.comment)
|
||||||
|
.to have_attributes(length: described_class::COMMENT_SIZE_LIMIT)
|
||||||
|
.and eq(long_comment[0...described_class::COMMENT_SIZE_LIMIT])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue