mirror of
https://github.com/lunaisnotaboy/mastodon.git
synced 2024-12-22 13:17:13 +00:00
Add coverage for api/v1 controllers (#3155)
This commit is contained in:
parent
f8ee136c29
commit
b6f6152e26
|
@ -17,6 +17,14 @@ RSpec.describe Api::V1::AccountsController, type: :controller do
|
|||
end
|
||||
end
|
||||
|
||||
describe 'GET #search' do
|
||||
it 'returns http success' do
|
||||
get :search, params: { q: 'query' }
|
||||
|
||||
expect(response).to have_http_status(:success)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'GET #verify_credentials' do
|
||||
it 'returns http success' do
|
||||
get :verify_credentials
|
||||
|
|
22
spec/controllers/api/v1/instances_controller_spec.rb
Normal file
22
spec/controllers/api/v1/instances_controller_spec.rb
Normal file
|
@ -0,0 +1,22 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Api::V1::InstancesController, type: :controller do
|
||||
render_views
|
||||
|
||||
let(:user) { Fabricate(:user, account: Fabricate(:account, username: 'alice')) }
|
||||
let(:token) { double acceptable?: true, 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(:success)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -11,6 +11,35 @@ RSpec.describe Api::V1::NotificationsController, type: :controller do
|
|||
allow(controller).to receive(:doorkeeper_token) { token }
|
||||
end
|
||||
|
||||
describe 'GET #show' do
|
||||
it 'returns http success' do
|
||||
notification = Fabricate(:notification, account: user.account)
|
||||
get :show, params: { id: notification.id }
|
||||
|
||||
expect(response).to have_http_status(:success)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'POST #dismiss' do
|
||||
it 'destroys the notification' do
|
||||
notification = Fabricate(:notification, account: user.account)
|
||||
post :dismiss, params: { id: notification.id }
|
||||
|
||||
expect(response).to have_http_status(:success)
|
||||
expect { notification.reload }.to raise_error(ActiveRecord::RecordNotFound)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'POST #clear' do
|
||||
it 'clears notifications for the account' do
|
||||
notification = Fabricate(:notification, account: user.account)
|
||||
post :clear
|
||||
|
||||
expect(notification.account.reload.notifications).to be_empty
|
||||
expect(response).to have_http_status(:success)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'GET #index' do
|
||||
before do
|
||||
first_status = PostStatusService.new.call(user.account, 'Test')
|
||||
|
|
32
spec/controllers/api/v1/reports_controller_spec.rb
Normal file
32
spec/controllers/api/v1/reports_controller_spec.rb
Normal file
|
@ -0,0 +1,32 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Api::V1::ReportsController, type: :controller do
|
||||
render_views
|
||||
|
||||
let(:user) { Fabricate(:user, account: Fabricate(:account, username: 'alice')) }
|
||||
let(:token) { double acceptable?: true, resource_owner_id: user.id }
|
||||
|
||||
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(:success)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'POST #create' do
|
||||
it 'creates a report' do
|
||||
status = Fabricate(:status)
|
||||
post :create, params: { status_ids: [status.id], account_id: status.account.id, comment: 'reasons' }
|
||||
|
||||
expect(status.reload.account.targeted_reports).not_to be_empty
|
||||
expect(response).to have_http_status(:success)
|
||||
end
|
||||
end
|
||||
end
|
22
spec/controllers/api/v1/search_controller_spec.rb
Normal file
22
spec/controllers/api/v1/search_controller_spec.rb
Normal file
|
@ -0,0 +1,22 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Api::V1::SearchController, type: :controller do
|
||||
render_views
|
||||
|
||||
let(:user) { Fabricate(:user, account: Fabricate(:account, username: 'alice')) }
|
||||
let(:token) { double acceptable?: true, resource_owner_id: user.id }
|
||||
|
||||
before do
|
||||
allow(controller).to receive(:doorkeeper_token) { token }
|
||||
end
|
||||
|
||||
describe 'GET #index' do
|
||||
it 'returns http success' do
|
||||
get :index, params: { q: 'test' }
|
||||
|
||||
expect(response).to have_http_status(:success)
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue