0
0
Fork 0

Enable Rubocop HTTP status rules (#23717)

This commit is contained in:
Nick Schonning 2023-02-19 21:16:40 -05:00 committed by GitHub
parent bd1d57c230
commit aef0051fd0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
32 changed files with 77 additions and 242 deletions

View file

@ -83,7 +83,7 @@ RSpec.describe Admin::AccountsController, type: :controller do
let(:target_role) { UserRole.find_by(name: 'Admin') }
it 'fails to memorialize account' do
is_expected.to have_http_status :forbidden
is_expected.to have_http_status 403
expect(account.reload).to_not be_memorial
end
end
@ -105,7 +105,7 @@ RSpec.describe Admin::AccountsController, type: :controller do
let(:target_role) { UserRole.find_by(name: 'Admin') }
it 'fails to memorialize account' do
is_expected.to have_http_status :forbidden
is_expected.to have_http_status 403
expect(account.reload).to_not be_memorial
end
end
@ -114,7 +114,7 @@ RSpec.describe Admin::AccountsController, type: :controller do
let(:target_role) { UserRole.find_by(name: 'Moderator') }
it 'fails to memorialize account' do
is_expected.to have_http_status :forbidden
is_expected.to have_http_status 403
expect(account.reload).to_not be_memorial
end
end
@ -141,7 +141,7 @@ RSpec.describe Admin::AccountsController, type: :controller do
let(:role) { UserRole.everyone }
it 'fails to enable account' do
is_expected.to have_http_status :forbidden
is_expected.to have_http_status 403
expect(user.reload).to be_disabled
end
end
@ -167,7 +167,7 @@ RSpec.describe Admin::AccountsController, type: :controller do
end
it 'logs action' do
is_expected.to have_http_status :found
is_expected.to have_http_status 302
log_item = Admin::ActionLog.last
@ -182,7 +182,7 @@ RSpec.describe Admin::AccountsController, type: :controller do
let(:role) { UserRole.everyone }
it 'fails to approve account' do
is_expected.to have_http_status :forbidden
is_expected.to have_http_status 403
expect(user.reload).to_not be_approved
end
end
@ -207,7 +207,7 @@ RSpec.describe Admin::AccountsController, type: :controller do
end
it 'logs action' do
is_expected.to have_http_status :found
is_expected.to have_http_status 302
log_item = Admin::ActionLog.last
@ -222,7 +222,7 @@ RSpec.describe Admin::AccountsController, type: :controller do
let(:role) { UserRole.everyone }
it 'fails to reject account' do
is_expected.to have_http_status :forbidden
is_expected.to have_http_status 403
expect(user.reload).to_not be_approved
end
end
@ -250,7 +250,7 @@ RSpec.describe Admin::AccountsController, type: :controller do
let(:role) { UserRole.everyone }
it 'fails to redownload' do
is_expected.to have_http_status :forbidden
is_expected.to have_http_status 403
end
end
end
@ -273,7 +273,7 @@ RSpec.describe Admin::AccountsController, type: :controller do
let(:role) { UserRole.everyone }
it 'fails to remove avatar' do
is_expected.to have_http_status :forbidden
is_expected.to have_http_status 403
end
end
end
@ -303,7 +303,7 @@ RSpec.describe Admin::AccountsController, type: :controller do
it 'fails to remove avatar' do
subject
expect(response).to have_http_status :forbidden
expect(response).to have_http_status 403
end
end
end

View file

@ -15,7 +15,7 @@ describe Admin::BaseController, type: :controller do
sign_in(Fabricate(:user))
get :success
expect(response).to have_http_status(:forbidden)
expect(response).to have_http_status(403)
end
it 'renders admin layout as a moderator' do

View file

@ -50,7 +50,7 @@ RSpec.describe Admin::InstancesController, type: :controller do
let(:role) { nil }
it 'fails to purge instance' do
is_expected.to have_http_status :forbidden
is_expected.to have_http_status 403
end
end
end

View file

@ -18,7 +18,7 @@ describe Admin::RolesController do
context 'when user does not have permission to manage roles' do
it 'returns http forbidden' do
expect(response).to have_http_status(:forbidden)
expect(response).to have_http_status(403)
end
end
@ -38,7 +38,7 @@ describe Admin::RolesController do
context 'when user does not have permission to manage roles' do
it 'returns http forbidden' do
expect(response).to have_http_status(:forbidden)
expect(response).to have_http_status(403)
end
end
@ -128,7 +128,7 @@ describe Admin::RolesController do
context 'when user does not have permission to manage roles' do
it 'returns http forbidden' do
expect(response).to have_http_status(:forbidden)
expect(response).to have_http_status(403)
end
end
@ -145,7 +145,7 @@ describe Admin::RolesController do
let(:role_position) { current_role.position + 1 }
it 'returns http forbidden' do
expect(response).to have_http_status(:forbidden)
expect(response).to have_http_status(403)
end
end
end
@ -165,7 +165,7 @@ describe Admin::RolesController do
context 'when user does not have permission to manage roles' do
it 'returns http forbidden' do
expect(response).to have_http_status(:forbidden)
expect(response).to have_http_status(403)
end
it 'does not update the role' do
@ -203,7 +203,7 @@ describe Admin::RolesController do
let(:role_position) { current_role.position + 1 }
it 'returns http forbidden' do
expect(response).to have_http_status(:forbidden)
expect(response).to have_http_status(403)
end
it 'does not update the role' do
@ -224,7 +224,7 @@ describe Admin::RolesController do
context 'when user does not have permission to manage roles' do
it 'returns http forbidden' do
expect(response).to have_http_status(:forbidden)
expect(response).to have_http_status(403)
end
end
@ -241,7 +241,7 @@ describe Admin::RolesController do
let(:role_position) { current_role.position + 1 }
it 'returns http forbidden' do
expect(response).to have_http_status(:forbidden)
expect(response).to have_http_status(403)
end
end
end

View file

@ -26,7 +26,7 @@ describe Admin::Users::RolesController do
let(:previous_role) { UserRole.create(name: 'Baz', permissions: UserRole::FLAGS[:administrator], position: 100) }
it 'returns http forbidden' do
expect(response).to have_http_status(:forbidden)
expect(response).to have_http_status(403)
end
end
end
@ -74,7 +74,7 @@ describe Admin::Users::RolesController do
end
it 'returns http forbidden' do
expect(response).to have_http_status(:forbidden)
expect(response).to have_http_status(403)
end
end
end

View file

@ -78,7 +78,7 @@ describe Api::V1::Accounts::CredentialsController do
end
it 'returns http unprocessable entity' do
expect(response).to have_http_status(:unprocessable_entity)
expect(response).to have_http_status(422)
end
end
end
@ -92,14 +92,14 @@ describe Api::V1::Accounts::CredentialsController do
describe 'GET #show' do
it 'returns http unauthorized' do
get :show
expect(response).to have_http_status(:unauthorized)
expect(response).to have_http_status(401)
end
end
describe 'PATCH #update' do
it 'returns http unauthorized' do
patch :update, params: { note: 'Foo' }
expect(response).to have_http_status(:unauthorized)
expect(response).to have_http_status(401)
end
end
end

View file

@ -16,7 +16,7 @@ describe Api::V1::Accounts::StatusesController do
it 'returns http success' do
get :index, params: { account_id: user.account.id, limit: 1 }
expect(response).to have_http_status(:ok)
expect(response).to have_http_status(200)
end
it 'returns expected headers' do
@ -29,7 +29,7 @@ describe Api::V1::Accounts::StatusesController do
it 'returns http success' do
get :index, params: { account_id: user.account.id, only_media: true }
expect(response).to have_http_status(:ok)
expect(response).to have_http_status(200)
end
end
@ -44,7 +44,7 @@ describe Api::V1::Accounts::StatusesController do
end
it 'returns http success' do
expect(response).to have_http_status(:ok)
expect(response).to have_http_status(200)
end
it 'returns posts along with self replies' do
@ -63,7 +63,7 @@ describe Api::V1::Accounts::StatusesController do
it 'returns http success' do
get :index, params: { account_id: user.account.id, pinned: true }
expect(response).to have_http_status(:ok)
expect(response).to have_http_status(200)
end
end
@ -79,7 +79,7 @@ describe Api::V1::Accounts::StatusesController do
it 'returns http success' do
get :index, params: { account_id: account.id, pinned: true }
expect(response).to have_http_status(:ok)
expect(response).to have_http_status(200)
end
context 'when user does not follow account' do

View file

@ -15,7 +15,7 @@ RSpec.describe Api::V1::Announcements::ReactionsController, type: :controller do
context 'without token' do
it 'returns http unauthorized' do
put :update, params: { announcement_id: announcement.id, id: '😂' }
expect(response).to have_http_status :unauthorized
expect(response).to have_http_status 401
end
end
@ -43,7 +43,7 @@ RSpec.describe Api::V1::Announcements::ReactionsController, type: :controller do
context 'without token' do
it 'returns http unauthorized' do
delete :destroy, params: { announcement_id: announcement.id, id: '😂' }
expect(response).to have_http_status :unauthorized
expect(response).to have_http_status 401
end
end

View file

@ -15,7 +15,7 @@ RSpec.describe Api::V1::AnnouncementsController, type: :controller do
context 'without token' do
it 'returns http unprocessable entity' do
get :index
expect(response).to have_http_status :unprocessable_entity
expect(response).to have_http_status 422
end
end
@ -35,7 +35,7 @@ RSpec.describe Api::V1::AnnouncementsController, type: :controller do
context 'without token' do
it 'returns http unauthorized' do
post :dismiss, params: { id: announcement.id }
expect(response).to have_http_status :unauthorized
expect(response).to have_http_status 401
end
end

View file

@ -36,7 +36,7 @@ describe Api::V1::Apps::CredentialsController do
describe 'GET #show' do
it 'returns http unauthorized' do
get :show
expect(response).to have_http_status(:unauthorized)
expect(response).to have_http_status(401)
end
end
end

View file

@ -10,7 +10,7 @@ RSpec.describe Api::V1::BookmarksController, type: :controller do
context 'without token' do
it 'returns http unauthorized' do
get :index
expect(response).to have_http_status :unauthorized
expect(response).to have_http_status 401
end
end
@ -24,7 +24,7 @@ RSpec.describe Api::V1::BookmarksController, type: :controller do
it 'returns http forbidden' do
get :index
expect(response).to have_http_status :forbidden
expect(response).to have_http_status 403
end
end
@ -38,7 +38,7 @@ RSpec.describe Api::V1::BookmarksController, type: :controller do
it 'returns http unprocessable entity' do
get :index
expect(response).to have_http_status :unprocessable_entity
expect(response).to have_http_status 422
end
end

View file

@ -16,7 +16,7 @@ RSpec.describe Api::V1::Emails::ConfirmationsController, type: :controller do
context 'from a random app' do
it 'returns http forbidden' do
post :create
expect(response).to have_http_status(:forbidden)
expect(response).to have_http_status(403)
end
end
@ -30,7 +30,7 @@ RSpec.describe Api::V1::Emails::ConfirmationsController, type: :controller do
it 'returns http forbidden' do
post :create
expect(response).to have_http_status(:forbidden)
expect(response).to have_http_status(403)
end
context 'but user changed e-mail and has not confirmed it' do
@ -57,7 +57,7 @@ RSpec.describe Api::V1::Emails::ConfirmationsController, type: :controller do
context 'without an oauth token' do
it 'returns http unauthorized' do
post :create
expect(response).to have_http_status(:unauthorized)
expect(response).to have_http_status(401)
end
end
end

View file

@ -10,7 +10,7 @@ RSpec.describe Api::V1::FavouritesController, type: :controller do
context 'without token' do
it 'returns http unauthorized' do
get :index
expect(response).to have_http_status :unauthorized
expect(response).to have_http_status 401
end
end
@ -24,7 +24,7 @@ RSpec.describe Api::V1::FavouritesController, type: :controller do
it 'returns http forbidden' do
get :index
expect(response).to have_http_status :forbidden
expect(response).to have_http_status 403
end
end
@ -38,7 +38,7 @@ RSpec.describe Api::V1::FavouritesController, type: :controller do
it 'returns http unprocessable entity' do
get :index
expect(response).to have_http_status :unprocessable_entity
expect(response).to have_http_status 422
end
end

View file

@ -19,7 +19,7 @@ RSpec.describe Api::V1::MediaController, type: :controller do
end
it 'returns http 422' do
expect(response).to have_http_status(:unprocessable_entity)
expect(response).to have_http_status(422)
end
end
@ -106,7 +106,7 @@ RSpec.describe Api::V1::MediaController, type: :controller do
it 'returns http not found' do
put :update, params: { id: media.id, description: 'Lorem ipsum!!!' }
expect(response).to have_http_status(:not_found)
expect(response).to have_http_status(404)
end
end
@ -126,7 +126,7 @@ RSpec.describe Api::V1::MediaController, type: :controller do
let(:status) { Fabricate(:status, account: user.account) }
it 'returns http not found' do
expect(response).to have_http_status(:not_found)
expect(response).to have_http_status(404)
end
end
end

View file

@ -36,7 +36,7 @@ describe Api::V1::Timelines::HomeController do
it 'returns http unprocessable entity' do
get :show
expect(response).to have_http_status(:unprocessable_entity)
expect(response).to have_http_status(422)
expect(response.headers['Link']).to be_nil
end
end

View file

@ -36,7 +36,7 @@ describe Api::V1::Timelines::ListController do
describe 'GET #show' do
it 'returns http not found' do
get :show, params: { id: list.id }
expect(response).to have_http_status(:not_found)
expect(response).to have_http_status(404)
end
end
end
@ -48,7 +48,7 @@ describe Api::V1::Timelines::ListController do
it 'returns http unprocessable entity' do
get :show, params: { id: list.id }
expect(response).to have_http_status(:unprocessable_entity)
expect(response).to have_http_status(422)
expect(response.headers['Link']).to be_nil
end
end

View file

@ -19,7 +19,7 @@ describe Api::Web::EmbedsController do
let(:url) { "http://#{Rails.configuration.x.web_domain}/@#{status.account.username}/#{status.id}" }
it 'returns a right response' do
expect(response).to have_http_status :ok
expect(response).to have_http_status 200
expect(body[:author_name]).to eq status.account.username
end
end
@ -37,7 +37,7 @@ describe Api::Web::EmbedsController do
let(:call_result) { { result: :ok } }
it 'returns a right response' do
expect(response).to have_http_status :ok
expect(response).to have_http_status 200
expect(body[:result]).to eq 'ok'
end
end
@ -46,7 +46,7 @@ describe Api::Web::EmbedsController do
let(:call_result) { nil }
it 'returns a right response' do
expect(response).to have_http_status :not_found
expect(response).to have_http_status 404
end
end
end

View file

@ -245,7 +245,7 @@ RSpec.describe Auth::RegistrationsController, type: :controller do
end
it 'returns http not found' do
expect(response).to have_http_status(:not_found)
expect(response).to have_http_status(404)
end
it 'does not delete user' do

View file

@ -422,7 +422,7 @@ RSpec.describe Auth::SessionsController, type: :controller do
it 'returns http success' do
get :webauthn_options
expect(response).to have_http_status :ok
expect(response).to have_http_status 200
end
end
end

View file

@ -29,7 +29,7 @@ describe ApplicationController, type: :controller do
it 'returns unauthorized when not signed in' do
get :index, format: :csv
expect(response).to have_http_status(:unauthorized)
expect(response).to have_http_status(401)
end
end
end

View file

@ -23,7 +23,7 @@ RSpec.describe Disputes::StrikesController, type: :controller do
let(:strike) { Fabricate(:account_warning) }
it 'returns http forbidden' do
expect(response).to have_http_status(:forbidden)
expect(response).to have_http_status(403)
end
end
end

View file

@ -32,7 +32,7 @@ describe Settings::ApplicationsController do
app.update!(owner: nil)
get :show, params: { id: app.id }
expect(response.status).to eq 404
expect(response).to have_http_status 404
end
end

View file

@ -24,7 +24,7 @@ describe Settings::SessionsController do
let(:id) { session_activation.id + 1000 }
it 'destroys session activation' do
is_expected.to have_http_status :not_found
is_expected.to have_http_status 404
end
end
end

View file

@ -13,7 +13,7 @@ describe SharesController do
before { get :show, params: { title: 'test title', text: 'test text', url: 'url1 url2' } }
it 'returns http success' do
expect(response).to have_http_status :ok
expect(response).to have_http_status 200
expect(body_classes).to eq 'modal-layout compose-standalone'
end
end