From 501ced4239ab685742706c18e7d5b9e418edb074 Mon Sep 17 00:00:00 2001 From: Matt Jankowski <matt@jankowski.online> Date: Wed, 2 Apr 2025 08:52:54 -0400 Subject: [PATCH] Add coverage for extra attributes scenario in `Admin::Trends::StatusesHelper#one_line_preview` method (#34353) --- spec/helpers/admin/trends/statuses_helper_spec.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/spec/helpers/admin/trends/statuses_helper_spec.rb b/spec/helpers/admin/trends/statuses_helper_spec.rb index fa5c337e9..6abc4569b 100644 --- a/spec/helpers/admin/trends/statuses_helper_spec.rb +++ b/spec/helpers/admin/trends/statuses_helper_spec.rb @@ -28,6 +28,19 @@ RSpec.describe Admin::Trends::StatusesHelper do end end + context 'with a remote status that has excessive attributes' do + let(:attr_limit) { Nokogiri::Gumbo::DEFAULT_MAX_ATTRIBUTES * 2 } + let(:html) { "<html><body #{(1..attr_limit).map { |x| "attr-#{x}" }.join(' ')}><p>text</p></body></html>" } + + let(:status) { Fabricate.build(:status, uri: 'https://host.example', text: html) } + + it 'renders a correct preview text' do + result = helper.one_line_preview(status) + + expect(result).to eq '' + end + end + context 'with a status that has empty text' do let(:status) { Fabricate.build(:status, text: '') }