From 191bf5876e73e586a04e642bc9b63e42721d30ad Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Thu, 4 Apr 2024 12:07:16 -0400 Subject: [PATCH] Add coverage for sanitize failure path in api/web/embeds spec (#29851) --- spec/requests/api/web/embeds_spec.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/spec/requests/api/web/embeds_spec.rb b/spec/requests/api/web/embeds_spec.rb index 6314f43aaf..0e6195204b 100644 --- a/spec/requests/api/web/embeds_spec.rb +++ b/spec/requests/api/web/embeds_spec.rb @@ -137,6 +137,18 @@ RSpec.describe '/api/web/embed' do end end + context 'when sanitizing the fragment fails' do + let(:call_result) { { html: 'ok' } } + + before { allow(Sanitize).to receive(:fragment).and_raise(ArgumentError) } + + it 'returns http not found' do + subject + + expect(response).to have_http_status(404) + end + end + context 'when failing to fetch OEmbed' do let(:call_result) { nil }