2023-03-16 21:07:24 +11:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
describe Api::V1::Instances::TranslationLanguagesController do
|
|
|
|
describe 'GET #show' do
|
|
|
|
context 'when no translation service is configured' do
|
2023-10-13 23:42:09 +11:00
|
|
|
it 'returns empty language matrix', :aggregate_failures do
|
2023-03-16 21:07:24 +11:00
|
|
|
get :show
|
|
|
|
|
|
|
|
expect(response).to have_http_status(200)
|
|
|
|
expect(body_as_json).to eq({})
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when a translation service is configured' do
|
|
|
|
before do
|
|
|
|
service = instance_double(TranslationService::DeepL, languages: { nil => %w(en de), 'en' => ['de'] })
|
2023-08-22 17:31:40 +10:00
|
|
|
allow(TranslationService).to receive_messages(configured?: true, configured: service)
|
2023-03-16 21:07:24 +11:00
|
|
|
end
|
|
|
|
|
2023-10-13 23:42:09 +11:00
|
|
|
it 'returns language matrix', :aggregate_failures do
|
2023-03-16 21:07:24 +11:00
|
|
|
get :show
|
|
|
|
|
|
|
|
expect(response).to have_http_status(200)
|
|
|
|
expect(body_as_json).to eq({ und: %w(en de), en: ['de'] })
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|