0
0
Fork 0

Fix missing content warning text in rss formatter (#32406)

This commit is contained in:
Matt Jankowski 2024-10-15 10:12:54 -04:00 committed by GitHub
parent b742ce9d09
commit b78597979a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 99 additions and 33 deletions

View file

@ -6,19 +6,57 @@ RSpec.describe FormattingHelper do
include Devise::Test::ControllerHelpers
describe '#rss_status_content_format' do
let(:status) { Fabricate(:status, text: 'Hello world<>', spoiler_text: 'This is a spoiler<>', poll: Fabricate(:poll, options: %w(Yes<> No))) }
let(:html) { helper.rss_status_content_format(status) }
subject { helper.rss_status_content_format(status) }
it 'renders the spoiler text' do
expect(html).to include('<p>This is a spoiler&lt;&gt;</p><hr>')
context 'with a simple status' do
let(:status) { Fabricate.build :status, text: 'Hello world' }
it 'renders the formatted elements' do
expect(parsed_result.css('p').first.text)
.to eq('Hello world')
end
end
it 'renders the status text' do
expect(html).to include('<p>Hello world&lt;&gt;</p>')
context 'with a spoiler and an emoji and a poll' do
let(:status) { Fabricate(:status, text: 'Hello :world: <>', spoiler_text: 'This is a spoiler<>', poll: Fabricate(:poll, options: %w(Yes<> No))) }
before { Fabricate :custom_emoji, shortcode: 'world' }
it 'renders the formatted elements' do
expect(spoiler_node.css('strong').text)
.to eq('Content warning:')
expect(spoiler_node.text)
.to include('This is a spoiler<>')
expect(content_node.text)
.to eq('Hello <>')
expect(content_node.css('img').first.to_h.symbolize_keys)
.to include(
rel: 'emoji',
title: ':world:'
)
expect(poll_node.css('radio').first.text)
.to eq('Yes<>')
expect(poll_node.css('radio').first.to_h.symbolize_keys)
.to include(
disabled: 'disabled'
)
end
def spoiler_node
parsed_result.css('p').first
end
def content_node
parsed_result.css('p')[1]
end
def poll_node
parsed_result.css('p').last
end
end
it 'renders the poll' do
expect(html).to include('<radio disabled="disabled">Yes&lt;&gt;</radio><br>')
def parsed_result
Nokogiri::HTML.fragment(subject)
end
end
end