diff options
author | Claire <claire.github-309c@sitedethib.com> | 2023-03-05 20:43:48 +0100 |
---|---|---|
committer | Claire <claire.github-309c@sitedethib.com> | 2023-03-05 20:46:56 +0100 |
commit | 7623e181247b4d2227b7774143514f6e1ca9253b (patch) | |
tree | b9a82790b7cb1f075769e7e5ca757b2ede322620 /spec/controllers/api/v1/statuses/translations_controller_spec.rb | |
parent | bb4e211c86270de6de8a78da96295208ee77dce1 (diff) | |
parent | dfa9843ac85d04e1facb2f757fd9288d8bb9fb2c (diff) |
Merge branch 'main' into glitch-soc/merge-upstream
Conflicts: - `README.md`: Upstream README has been changed, but we have a completely different one. Kept our `README.md`. - `lib/sanitize_ext/sanitize_config.rb`: Upstream added support for more incoming HTML tags (a large subset of what glitch-soc accepts). Change the code style to match upstream's but otherwise do not change our code. - `spec/lib/sanitize_config_spec.rb`: Upstream added support for more incoming HTML tags (a large subset of what glitch-soc accepts). Kept our version, since the tests are mostly glitch-soc's, except for cases which are purposefuly different.
Diffstat (limited to 'spec/controllers/api/v1/statuses/translations_controller_spec.rb')
-rw-r--r-- | spec/controllers/api/v1/statuses/translations_controller_spec.rb | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/spec/controllers/api/v1/statuses/translations_controller_spec.rb b/spec/controllers/api/v1/statuses/translations_controller_spec.rb new file mode 100644 index 000000000..2deea9fc0 --- /dev/null +++ b/spec/controllers/api/v1/statuses/translations_controller_spec.rb @@ -0,0 +1,33 @@ +# frozen_string_literal: true + +require 'rails_helper' + +describe Api::V1::Statuses::TranslationsController do + render_views + + let(:user) { Fabricate(:user) } + let(:app) { Fabricate(:application, name: 'Test app', website: 'http://testapp.com') } + let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: 'read:statuses', application: app) } + + context 'with an oauth token' do + before do + allow(controller).to receive(:doorkeeper_token) { token } + end + + describe 'POST #create' do + let(:status) { Fabricate(:status, account: user.account, text: 'Hola', language: 'es') } + + before do + translation = TranslationService::Translation.new(text: 'Hello') + service = instance_double(TranslationService::DeepL, translate: translation, supported?: true) + allow(TranslationService).to receive(:configured?).and_return(true) + allow(TranslationService).to receive(:configured).and_return(service) + post :create, params: { status_id: status.id } + end + + it 'returns http success' do + expect(response).to have_http_status(200) + end + end + end +end |