1
0
Fork 0
mirror of https://github.com/mastodon/mastodon.git synced 2024-08-20 21:08:15 -07:00

Move api/v1/statuses/* to request spec (#28954)

This commit is contained in:
Matt Jankowski 2024-01-26 12:45:54 -05:00 committed by GitHub
parent 44f6d285af
commit ff8937aa2c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 30 additions and 50 deletions

View file

@ -2,23 +2,18 @@
require 'rails_helper'
describe Api::V1::Statuses::HistoriesController do
render_views
describe 'API V1 Statuses Histories' do
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) }
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: scopes) }
let(:scopes) { 'read:statuses' }
let(:headers) { { 'Authorization' => "Bearer #{token.token}" } }
context 'with an oauth token' do
before do
allow(controller).to receive(:doorkeeper_token) { token }
end
describe 'GET #show' do
describe 'GET /api/v1/statuses/:status_id/history' do
let(:status) { Fabricate(:status, account: user.account) }
before do
get :show, params: { status_id: status.id }
get "/api/v1/statuses/#{status.id}/history", headers: headers
end
it 'returns http success' do

View file

@ -2,23 +2,18 @@
require 'rails_helper'
describe Api::V1::Statuses::MutesController do
render_views
describe 'API V1 Statuses Mutes' do
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: 'write:mutes', application: app) }
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: scopes) }
let(:scopes) { 'write:mutes' }
let(:headers) { { 'Authorization' => "Bearer #{token.token}" } }
context 'with an oauth token' do
before do
allow(controller).to receive(:doorkeeper_token) { token }
end
describe 'POST #create' do
describe 'POST /api/v1/statuses/:status_id/mute' do
let(:status) { Fabricate(:status, account: user.account) }
before do
post :create, params: { status_id: status.id }
post "/api/v1/statuses/#{status.id}/mute", headers: headers
end
it 'creates a conversation mute', :aggregate_failures do
@ -27,12 +22,12 @@ describe Api::V1::Statuses::MutesController do
end
end
describe 'POST #destroy' do
describe 'POST /api/v1/statuses/:status_id/unmute' do
let(:status) { Fabricate(:status, account: user.account) }
before do
user.account.mute_conversation!(status.conversation)
post :destroy, params: { status_id: status.id }
post "/api/v1/statuses/#{status.id}/unmute", headers: headers
end
it 'destroys the conversation mute', :aggregate_failures do

View file

@ -2,23 +2,18 @@
require 'rails_helper'
describe Api::V1::Statuses::ReblogsController do
render_views
describe 'API V1 Statuses Reblogs' do
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: 'write:statuses', application: app) }
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: scopes) }
let(:scopes) { 'write:statuses' }
let(:headers) { { 'Authorization' => "Bearer #{token.token}" } }
context 'with an oauth token' do
before do
allow(controller).to receive(:doorkeeper_token) { token }
end
describe 'POST #create' do
describe 'POST /api/v1/statuses/:status_id/reblog' do
let(:status) { Fabricate(:status, account: user.account) }
before do
post :create, params: { status_id: status.id }
post "/api/v1/statuses/#{status.id}/reblog", headers: headers
end
context 'with public status' do
@ -46,13 +41,13 @@ describe Api::V1::Statuses::ReblogsController do
end
end
describe 'POST #destroy', :sidekiq_inline do
describe 'POST /api/v1/statuses/:status_id/unreblog', :sidekiq_inline do
context 'with public status' do
let(:status) { Fabricate(:status, account: user.account) }
before do
ReblogService.new.call(user.account, status)
post :destroy, params: { status_id: status.id }
post "/api/v1/statuses/#{status.id}/unreblog", headers: headers
end
it 'destroys the reblog', :aggregate_failures do
@ -76,7 +71,7 @@ describe Api::V1::Statuses::ReblogsController do
before do
ReblogService.new.call(user.account, status)
status.account.block!(user.account)
post :destroy, params: { status_id: status.id }
post "/api/v1/statuses/#{status.id}/unreblog", headers: headers
end
it 'destroys the reblog', :aggregate_failures do
@ -98,7 +93,7 @@ describe Api::V1::Statuses::ReblogsController do
let(:status) { Fabricate(:status, visibility: :private) }
before do
post :destroy, params: { status_id: status.id }
post "/api/v1/statuses/#{status.id}/unreblog", headers: headers
end
it 'returns http not found' do

View file

@ -2,19 +2,14 @@
require 'rails_helper'
describe Api::V1::Statuses::TranslationsController do
render_views
describe 'API V1 Statuses Translations' do
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) }
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: scopes) }
let(:scopes) { 'read:statuses' }
let(:headers) { { 'Authorization' => "Bearer #{token.token}" } }
context 'with an oauth token' do
before do
allow(controller).to receive(:doorkeeper_token) { token }
end
describe 'POST #create' do
describe 'POST /api/v1/statuses/:status_id/translate' do
let(:status) { Fabricate(:status, account: user.account, text: 'Hola', language: 'es') }
before do
@ -22,7 +17,7 @@ describe Api::V1::Statuses::TranslationsController do
service = instance_double(TranslationService::DeepL, translate: [translation])
allow(TranslationService).to receive_messages(configured?: true, configured: service)
Rails.cache.write('translation_service/languages', { 'es' => ['en'] })
post :create, params: { status_id: status.id }
post "/api/v1/statuses/#{status.id}/translate", headers: headers
end
it 'returns http success' do