0
0
Fork 0

Convert /instances/* controller specs to request specs (#27988)

Co-authored-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
Matt Jankowski 2023-11-20 06:05:28 -05:00 committed by GitHub
parent 718c95e7af
commit 876f5b1d12
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 349 additions and 192 deletions

View file

@ -1,21 +0,0 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe Api::V1::Instances::ActivityController do
describe 'GET #show' do
it 'returns 200' do
get :show
expect(response).to have_http_status(200)
end
context 'with !Setting.activity_api_enabled' do
it 'returns 404' do
Setting.activity_api_enabled = false
get :show
expect(response).to have_http_status(404)
end
end
end
end

View file

@ -1,16 +0,0 @@
# frozen_string_literal: true
require 'rails_helper'
describe Api::V1::Instances::DomainBlocksController do
render_views
describe 'GET #index' do
it 'returns http success' do
Setting.show_domain_blocks = 'all'
get :index
expect(response).to have_http_status(200)
end
end
end

View file

@ -1,15 +0,0 @@
# frozen_string_literal: true
require 'rails_helper'
describe Api::V1::Instances::ExtendedDescriptionsController do
render_views
describe 'GET #show' do
it 'returns http success' do
get :show
expect(response).to have_http_status(200)
end
end
end

View file

@ -1,21 +0,0 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe Api::V1::Instances::PeersController do
describe 'GET #index' do
it 'returns 200' do
get :index
expect(response).to have_http_status(200)
end
context 'with !Setting.peers_api_enabled' do
it 'returns 404' do
Setting.peers_api_enabled = false
get :index
expect(response).to have_http_status(404)
end
end
end
end

View file

@ -1,15 +0,0 @@
# frozen_string_literal: true
require 'rails_helper'
describe Api::V1::Instances::PrivacyPoliciesController do
render_views
describe 'GET #show' do
it 'returns http success' do
get :show
expect(response).to have_http_status(200)
end
end
end

View file

@ -1,15 +0,0 @@
# frozen_string_literal: true
require 'rails_helper'
describe Api::V1::Instances::RulesController do
render_views
describe 'GET #index' do
it 'returns http success' do
get :index
expect(response).to have_http_status(200)
end
end
end

View file

@ -1,30 +0,0 @@
# 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
it 'returns empty language matrix', :aggregate_failures do
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'] })
allow(TranslationService).to receive_messages(configured?: true, configured: service)
end
it 'returns language matrix', :aggregate_failures do
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

View file

@ -1,22 +0,0 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe Api::V1::InstancesController do
render_views
let(:user) { Fabricate(:user) }
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id) }
before do
allow(controller).to receive(:doorkeeper_token) { token }
end
describe 'GET #show' do
it 'returns http success' do
get :show
expect(response).to have_http_status(200)
end
end
end

View file

@ -1,22 +0,0 @@
# frozen_string_literal: true
require 'rails_helper'
describe Api::V2::InstancesController do
render_views
let(:user) { Fabricate(:user) }
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id) }
before do
allow(controller).to receive(:doorkeeper_token) { token }
end
describe 'GET #show' do
it 'returns http success' do
get :show
expect(response).to have_http_status(200)
end
end
end