Merge commit 'c37bc5a8a94758e19b2d50db5e7816a96cec5cf4' into glitch-soc/merge-upstream

This commit is contained in:
Claire
2026-03-17 18:01:07 +01:00
65 changed files with 528 additions and 240 deletions

View File

@@ -19,6 +19,19 @@ RSpec.describe TranslationService::DeepL do
end
describe '#translate' do
context 'with invalid body response' do
before do
stub_request(:post, 'https://api.deepl.com/v2/translate')
.with(body: 'text=Hasta+la+vista&source_lang=ES&target_lang=en&tag_handling=html')
.to_return(body: 'XXX')
end
it 'handles error and re-raises' do
expect { service.translate(['Hasta la vista'], 'es', 'en') }
.to raise_error(TranslationService::UnexpectedResponseError)
end
end
it 'returns translation with specified source language' do
stub_request(:post, 'https://api.deepl.com/v2/translate')
.with(body: 'text=Hasta+la+vista&source_lang=ES&target_lang=en&tag_handling=html')

View File

@@ -29,6 +29,19 @@ RSpec.describe TranslationService::LibreTranslate do
end
describe '#translate' do
context 'with invalid body response' do
before do
stub_request(:post, 'https://libretranslate.example.com/translate')
.with(body: '{"q":["Hasta la vista"],"source":"es","target":"en","format":"html","api_key":"my-api-key"}')
.to_return(body: 'XXX')
end
it 'handles error and re-raises' do
expect { service.translate(['Hasta la vista'], 'es', 'en') }
.to raise_error(TranslationService::UnexpectedResponseError)
end
end
it 'returns translation with specified source language' do
stub_request(:post, 'https://libretranslate.example.com/translate')
.with(body: '{"q":["Hasta la vista"],"source":"es","target":"en","format":"html","api_key":"my-api-key"}')

View File

@@ -37,6 +37,16 @@ RSpec.describe Webfinger do
end
end
context 'when response body is not parsable' do
it 'raises an error' do
stub_request(:get, 'https://example.com/.well-known/webfinger?resource=acct:alice@example.com')
.to_return(body: 'XXX', headers: { 'Content-Type': 'application/jrd+json' })
expect { subject }
.to raise_error(Webfinger::Error)
end
end
context 'when webfinger fails and host meta is used' do
before { stub_request(:get, 'https://example.com/.well-known/webfinger?resource=acct:alice@example.com').to_return(status: 404) }