Merge commit 'a5b4a2b7e7
' into kb-draft-5.21-lts
This commit is contained in:
commit
6896542a76
33 changed files with 338 additions and 109 deletions
|
@ -13,6 +13,17 @@ describe Api::V1::ScheduledStatusesController do
|
|||
allow(controller).to receive(:doorkeeper_token) { token }
|
||||
end
|
||||
|
||||
context 'with an application token' do
|
||||
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: nil, scopes: 'read:statuses') }
|
||||
|
||||
it 'returns http unprocessable entity' do
|
||||
get :index
|
||||
|
||||
expect(response)
|
||||
.to have_http_status(422)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'GET #index' do
|
||||
it 'returns http success' do
|
||||
get :index
|
||||
|
|
|
@ -9,6 +9,26 @@ describe Api::V1::Statuses::TranslationsController do
|
|||
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 application token' do
|
||||
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: nil, scopes: 'read:statuses', application: app) }
|
||||
|
||||
before do
|
||||
allow(controller).to receive(:doorkeeper_token) { token }
|
||||
end
|
||||
|
||||
describe 'POST /api/v1/statuses/:status_id/translate' do
|
||||
let(:status) { Fabricate(:status, account: user.account, text: 'Hola', language: 'es') }
|
||||
|
||||
before do
|
||||
post :create, params: { status_id: status.id }
|
||||
end
|
||||
|
||||
it 'returns http unprocessable entity' do
|
||||
expect(response).to have_http_status(422)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'with an oauth token' do
|
||||
before do
|
||||
allow(controller).to receive(:doorkeeper_token) { token }
|
||||
|
|
|
@ -182,6 +182,46 @@ RSpec.describe Api::V1::StatusesController do
|
|||
expect(response.headers['X-RateLimit-Remaining']).to eq '0'
|
||||
end
|
||||
end
|
||||
|
||||
context 'with missing thread' do
|
||||
subject { post :create, params: params }
|
||||
|
||||
let(:params) { { status: 'Hello world', in_reply_to_id: 0 } }
|
||||
|
||||
it 'returns http not found' do
|
||||
subject
|
||||
|
||||
expect(response).to have_http_status(404)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when scheduling a status' do
|
||||
subject { post :create, params: params }
|
||||
|
||||
let(:params) { { status: 'Hello world', scheduled_at: 10.minutes.from_now } }
|
||||
let(:account) { user.account }
|
||||
|
||||
it 'returns HTTP 200' do
|
||||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
end
|
||||
|
||||
it 'creates a scheduled status' do
|
||||
expect { subject }.to change { account.scheduled_statuses.count }.from(0).to(1)
|
||||
end
|
||||
|
||||
context 'when the scheduling time is less than 5 minutes' do
|
||||
let(:params) { { status: 'Hello world', scheduled_at: 4.minutes.from_now } }
|
||||
|
||||
it 'does not create a scheduled status', :aggregate_failures do
|
||||
subject
|
||||
|
||||
expect(response).to have_http_status(422)
|
||||
expect(account.scheduled_statuses).to be_empty
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'DELETE #destroy' do
|
||||
|
|
|
@ -6,7 +6,8 @@ describe Api::V1::Timelines::TagController do
|
|||
render_views
|
||||
|
||||
let(:user) { Fabricate(:user) }
|
||||
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: 'read:statuses') }
|
||||
let(:scopes) { 'read:statuses' }
|
||||
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: scopes) }
|
||||
|
||||
before do
|
||||
allow(controller).to receive(:doorkeeper_token) { token }
|
||||
|
@ -48,13 +49,23 @@ describe Api::V1::Timelines::TagController do
|
|||
Form::AdminSettings.new(timeline_preview: false).save
|
||||
end
|
||||
|
||||
context 'when the user is not authenticated' do
|
||||
context 'without an access token' do
|
||||
let(:token) { nil }
|
||||
|
||||
it 'returns http unauthorized' do
|
||||
it 'returns http unprocessable entity' do
|
||||
subject
|
||||
|
||||
expect(response).to have_http_status(401)
|
||||
expect(response).to have_http_status(422)
|
||||
end
|
||||
end
|
||||
|
||||
context 'with an application access token, not bound to a user' do
|
||||
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: nil, scopes: scopes) }
|
||||
|
||||
it 'returns http unprocessable entity' do
|
||||
subject
|
||||
|
||||
expect(response).to have_http_status(422)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue