Browse Source

Specs api v1 controllers (#23930)

closed-social-glitch-2
Matt Jankowski 1 year ago
committed by GitHub
parent
commit
ad585fb195
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
25 changed files with 537 additions and 0 deletions
  1. +23
    -0
      spec/controllers/api/v1/accounts/familiar_followers_controller_spec.rb
  2. +23
    -0
      spec/controllers/api/v1/accounts/featured_tags_controller_spec.rb
  3. +23
    -0
      spec/controllers/api/v1/accounts/identity_proofs_controller_spec.rb
  4. +23
    -0
      spec/controllers/api/v1/accounts/lookup_controller_spec.rb
  5. +23
    -0
      spec/controllers/api/v1/admin/canonical_email_blocks_controller_spec.rb
  6. +23
    -0
      spec/controllers/api/v1/admin/dimensions_controller_spec.rb
  7. +23
    -0
      spec/controllers/api/v1/admin/email_domain_blocks_controller_spec.rb
  8. +23
    -0
      spec/controllers/api/v1/admin/ip_blocks_controller_spec.rb
  9. +23
    -0
      spec/controllers/api/v1/admin/measures_controller_spec.rb
  10. +23
    -0
      spec/controllers/api/v1/admin/retention_controller_spec.rb
  11. +23
    -0
      spec/controllers/api/v1/admin/trends/links_controller_spec.rb
  12. +23
    -0
      spec/controllers/api/v1/admin/trends/statuses_controller_spec.rb
  13. +23
    -0
      spec/controllers/api/v1/admin/trends/tags_controller_spec.rb
  14. +23
    -0
      spec/controllers/api/v1/directories_controller_spec.rb
  15. +23
    -0
      spec/controllers/api/v1/featured_tags/suggestions_controller_spec.rb
  16. +23
    -0
      spec/controllers/api/v1/featured_tags_controller_spec.rb
  17. +16
    -0
      spec/controllers/api/v1/instances/domain_blocks_controller_spec.rb
  18. +15
    -0
      spec/controllers/api/v1/instances/extended_descriptions_controller_spec.rb
  19. +15
    -0
      spec/controllers/api/v1/instances/privacy_policies_controller_spec.rb
  20. +15
    -0
      spec/controllers/api/v1/instances/rules_controller_spec.rb
  21. +23
    -0
      spec/controllers/api/v1/preferences_controller_spec.rb
  22. +23
    -0
      spec/controllers/api/v1/scheduled_statuses_controller_spec.rb
  23. +32
    -0
      spec/controllers/api/v1/statuses/translations_controller_spec.rb
  24. +15
    -0
      spec/controllers/api/v1/trends/links_controller_spec.rb
  25. +15
    -0
      spec/controllers/api/v1/trends/statuses_controller_spec.rb

+ 23
- 0
spec/controllers/api/v1/accounts/familiar_followers_controller_spec.rb View File

@ -0,0 +1,23 @@
# frozen_string_literal: true
require 'rails_helper'
describe Api::V1::Accounts::FamiliarFollowersController do
render_views
let(:user) { Fabricate(:user) }
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: 'read:follows') }
let(:account) { Fabricate(:account) }
before do
allow(controller).to receive(:doorkeeper_token) { token }
end
describe 'GET #index' do
it 'returns http success' do
get :index, params: { account_id: account.id, limit: 2 }
expect(response).to have_http_status(200)
end
end
end

+ 23
- 0
spec/controllers/api/v1/accounts/featured_tags_controller_spec.rb View File

@ -0,0 +1,23 @@
# frozen_string_literal: true
require 'rails_helper'
describe Api::V1::Accounts::FeaturedTagsController do
render_views
let(:user) { Fabricate(:user) }
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: 'read:accounts') }
let(:account) { Fabricate(:account) }
before do
allow(controller).to receive(:doorkeeper_token) { token }
end
describe 'GET #index' do
it 'returns http success' do
get :index, params: { account_id: account.id, limit: 2 }
expect(response).to have_http_status(200)
end
end
end

+ 23
- 0
spec/controllers/api/v1/accounts/identity_proofs_controller_spec.rb View File

@ -0,0 +1,23 @@
# frozen_string_literal: true
require 'rails_helper'
describe Api::V1::Accounts::IdentityProofsController do
render_views
let(:user) { Fabricate(:user) }
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: 'read:accounts') }
let(:account) { Fabricate(:account) }
before do
allow(controller).to receive(:doorkeeper_token) { token }
end
describe 'GET #index' do
it 'returns http success' do
get :index, params: { account_id: account.id, limit: 2 }
expect(response).to have_http_status(200)
end
end
end

+ 23
- 0
spec/controllers/api/v1/accounts/lookup_controller_spec.rb View File

@ -0,0 +1,23 @@
# frozen_string_literal: true
require 'rails_helper'
describe Api::V1::Accounts::LookupController do
render_views
let(:user) { Fabricate(:user) }
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: 'read:accounts') }
let(:account) { Fabricate(:account) }
before do
allow(controller).to receive(:doorkeeper_token) { token }
end
describe 'GET #show' do
it 'returns http success' do
get :show, params: { account_id: account.id, acct: account.acct }
expect(response).to have_http_status(200)
end
end
end

+ 23
- 0
spec/controllers/api/v1/admin/canonical_email_blocks_controller_spec.rb View File

@ -0,0 +1,23 @@
# frozen_string_literal: true
require 'rails_helper'
describe Api::V1::Admin::CanonicalEmailBlocksController do
render_views
let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: 'admin:read') }
let(:account) { Fabricate(:account) }
before do
allow(controller).to receive(:doorkeeper_token) { token }
end
describe 'GET #index' do
it 'returns http success' do
get :index, params: { account_id: account.id, limit: 2 }
expect(response).to have_http_status(200)
end
end
end

+ 23
- 0
spec/controllers/api/v1/admin/dimensions_controller_spec.rb View File

@ -0,0 +1,23 @@
# frozen_string_literal: true
require 'rails_helper'
describe Api::V1::Admin::DimensionsController do
render_views
let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: 'admin:read') }
let(:account) { Fabricate(:account) }
before do
allow(controller).to receive(:doorkeeper_token) { token }
end
describe 'POST #create' do
it 'returns http success' do
post :create, params: { account_id: account.id, limit: 2 }
expect(response).to have_http_status(200)
end
end
end

+ 23
- 0
spec/controllers/api/v1/admin/email_domain_blocks_controller_spec.rb View File

@ -0,0 +1,23 @@
# frozen_string_literal: true
require 'rails_helper'
describe Api::V1::Admin::EmailDomainBlocksController do
render_views
let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: 'admin:read') }
let(:account) { Fabricate(:account) }
before do
allow(controller).to receive(:doorkeeper_token) { token }
end
describe 'GET #index' do
it 'returns http success' do
get :index, params: { account_id: account.id, limit: 2 }
expect(response).to have_http_status(200)
end
end
end

+ 23
- 0
spec/controllers/api/v1/admin/ip_blocks_controller_spec.rb View File

@ -0,0 +1,23 @@
# frozen_string_literal: true
require 'rails_helper'
describe Api::V1::Admin::IpBlocksController do
render_views
let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: 'admin:read') }
let(:account) { Fabricate(:account) }
before do
allow(controller).to receive(:doorkeeper_token) { token }
end
describe 'GET #index' do
it 'returns http success' do
get :index, params: { account_id: account.id, limit: 2 }
expect(response).to have_http_status(200)
end
end
end

+ 23
- 0
spec/controllers/api/v1/admin/measures_controller_spec.rb View File

@ -0,0 +1,23 @@
# frozen_string_literal: true
require 'rails_helper'
describe Api::V1::Admin::MeasuresController do
render_views
let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: 'admin:read') }
let(:account) { Fabricate(:account) }
before do
allow(controller).to receive(:doorkeeper_token) { token }
end
describe 'POST #create' do
it 'returns http success' do
post :create, params: { account_id: account.id, limit: 2 }
expect(response).to have_http_status(200)
end
end
end

+ 23
- 0
spec/controllers/api/v1/admin/retention_controller_spec.rb View File

@ -0,0 +1,23 @@
# frozen_string_literal: true
require 'rails_helper'
describe Api::V1::Admin::RetentionController do
render_views
let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: 'admin:read') }
let(:account) { Fabricate(:account) }
before do
allow(controller).to receive(:doorkeeper_token) { token }
end
describe 'POST #create' do
it 'returns http success' do
post :create, params: { account_id: account.id, limit: 2 }
expect(response).to have_http_status(200)
end
end
end

+ 23
- 0
spec/controllers/api/v1/admin/trends/links_controller_spec.rb View File

@ -0,0 +1,23 @@
# frozen_string_literal: true
require 'rails_helper'
describe Api::V1::Admin::Trends::LinksController do
render_views
let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: 'admin:read') }
let(:account) { Fabricate(:account) }
before do
allow(controller).to receive(:doorkeeper_token) { token }
end
describe 'GET #index' do
it 'returns http success' do
get :index, params: { account_id: account.id, limit: 2 }
expect(response).to have_http_status(200)
end
end
end

+ 23
- 0
spec/controllers/api/v1/admin/trends/statuses_controller_spec.rb View File

@ -0,0 +1,23 @@
# frozen_string_literal: true
require 'rails_helper'
describe Api::V1::Admin::Trends::StatusesController do
render_views
let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: 'admin:read') }
let(:account) { Fabricate(:account) }
before do
allow(controller).to receive(:doorkeeper_token) { token }
end
describe 'GET #index' do
it 'returns http success' do
get :index, params: { account_id: account.id, limit: 2 }
expect(response).to have_http_status(200)
end
end
end

+ 23
- 0
spec/controllers/api/v1/admin/trends/tags_controller_spec.rb View File

@ -0,0 +1,23 @@
# frozen_string_literal: true
require 'rails_helper'
describe Api::V1::Admin::Trends::TagsController do
render_views
let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: 'admin:read') }
let(:account) { Fabricate(:account) }
before do
allow(controller).to receive(:doorkeeper_token) { token }
end
describe 'GET #index' do
it 'returns http success' do
get :index, params: { account_id: account.id, limit: 2 }
expect(response).to have_http_status(200)
end
end
end

+ 23
- 0
spec/controllers/api/v1/directories_controller_spec.rb View File

@ -0,0 +1,23 @@
# frozen_string_literal: true
require 'rails_helper'
describe Api::V1::DirectoriesController do
render_views
let(:user) { Fabricate(:user) }
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: 'read:follows') }
let(:account) { Fabricate(:account) }
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

+ 23
- 0
spec/controllers/api/v1/featured_tags/suggestions_controller_spec.rb View File

@ -0,0 +1,23 @@
# frozen_string_literal: true
require 'rails_helper'
describe Api::V1::FeaturedTags::SuggestionsController do
render_views
let(:user) { Fabricate(:user) }
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: 'read:accounts') }
let(:account) { Fabricate(:account) }
before do
allow(controller).to receive(:doorkeeper_token) { token }
end
describe 'GET #index' do
it 'returns http success' do
get :index, params: { account_id: account.id, limit: 2 }
expect(response).to have_http_status(200)
end
end
end

+ 23
- 0
spec/controllers/api/v1/featured_tags_controller_spec.rb View File

@ -0,0 +1,23 @@
# frozen_string_literal: true
require 'rails_helper'
describe Api::V1::FeaturedTagsController do
render_views
let(:user) { Fabricate(:user) }
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: 'read:accounts') }
let(:account) { Fabricate(:account) }
before do
allow(controller).to receive(:doorkeeper_token) { token }
end
describe 'GET #index' do
it 'returns http success' do
get :index, params: { account_id: account.id, limit: 2 }
expect(response).to have_http_status(200)
end
end
end

+ 16
- 0
spec/controllers/api/v1/instances/domain_blocks_controller_spec.rb View File

@ -0,0 +1,16 @@
# 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

+ 15
- 0
spec/controllers/api/v1/instances/extended_descriptions_controller_spec.rb View File

@ -0,0 +1,15 @@
# 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

+ 15
- 0
spec/controllers/api/v1/instances/privacy_policies_controller_spec.rb View File

@ -0,0 +1,15 @@
# 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

+ 15
- 0
spec/controllers/api/v1/instances/rules_controller_spec.rb View File

@ -0,0 +1,15 @@
# 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

+ 23
- 0
spec/controllers/api/v1/preferences_controller_spec.rb View File

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

+ 23
- 0
spec/controllers/api/v1/scheduled_statuses_controller_spec.rb View File

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

+ 32
- 0
spec/controllers/api/v1/statuses/translations_controller_spec.rb View File

@ -0,0 +1,32 @@
# 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) }
before do
translation = TranslationService::Translation.new(text: 'Hello')
service = instance_double(TranslationService::DeepL, translate: translation)
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

+ 15
- 0
spec/controllers/api/v1/trends/links_controller_spec.rb View File

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

+ 15
- 0
spec/controllers/api/v1/trends/statuses_controller_spec.rb View File

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

Loading…
Cancel
Save