Fix quotes with CWs but no text not having fallback link (#37361)

This commit is contained in:
Claire 2026-01-05 11:35:35 +01:00
parent 1c5461fffe
commit ad4ba5aa00
3 changed files with 22 additions and 3 deletions

View file

@ -15,8 +15,6 @@ class HtmlAwareFormatter
end end
def to_s def to_s
return ''.html_safe if text.blank?
if local? if local?
linkify linkify
else else
@ -29,6 +27,8 @@ class HtmlAwareFormatter
private private
def reformat def reformat
return ''.html_safe if text.blank?
Sanitize.fragment(text, Sanitize::Config::MASTODON_STRICT) Sanitize.fragment(text, Sanitize::Config::MASTODON_STRICT)
end end

View file

@ -344,7 +344,7 @@ RSpec.describe '/api/v1/statuses' do
.to start_with('application/json') .to start_with('application/json')
expect(response.parsed_body[:quote]).to be_present expect(response.parsed_body[:quote]).to be_present
expect(response.parsed_body[:spoiler_text]).to eq 'this is a CW' expect(response.parsed_body[:spoiler_text]).to eq 'this is a CW'
expect(response.parsed_body[:content]).to eq '' expect(response.parsed_body[:content]).to match(/RE: /)
expect(response.headers['X-RateLimit-Limit']).to eq RateLimiter::FAMILIES[:statuses][:limit].to_s expect(response.headers['X-RateLimit-Limit']).to eq RateLimiter::FAMILIES[:statuses][:limit].to_s
expect(response.headers['X-RateLimit-Remaining']).to eq (RateLimiter::FAMILIES[:statuses][:limit] - 1).to_s expect(response.headers['X-RateLimit-Remaining']).to eq (RateLimiter::FAMILIES[:statuses][:limit] - 1).to_s
end end

View file

@ -19,6 +19,25 @@ RSpec.describe REST::StatusSerializer do
let(:bob) { Fabricate(:account, username: 'bob', domain: 'other.com') } let(:bob) { Fabricate(:account, username: 'bob', domain: 'other.com') }
let(:status) { Fabricate(:status, account: alice) } let(:status) { Fabricate(:status, account: alice) }
context 'with a local status' do
context 'with a quote and a CW but no contents' do
let(:quoted_status) { Fabricate(:status, account: alice) }
let(:status) { Fabricate.build(:status, account: alice, text: '', spoiler_text: 'this is a CW') }
before do
Fabricate(:quote, status: status, quoted_status: quoted_status, state: :accepted)
end
it 'renders the status with a CW and fallback link' do
expect(subject)
.to include(
'content' => /RE: <a/,
'spoiler_text' => 'this is a CW'
)
end
end
end
context 'with a remote status' do context 'with a remote status' do
let(:status) { Fabricate(:status, account: bob) } let(:status) { Fabricate(:status, account: bob) }