Enable Rubocop HTTP status rules (#23717)

main
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

@ -88,6 +88,9 @@ Metrics/ModuleLength:
Metrics/PerceivedComplexity: Metrics/PerceivedComplexity:
Max: 16 # RuboCop default 8 Max: 16 # RuboCop default 8
Rails/HttpStatus:
EnforcedStyle: numeric
Rails/Exit: Rails/Exit:
Exclude: Exclude:
- 'lib/mastodon/*_cli.rb' - 'lib/mastodon/*_cli.rb'
@ -97,6 +100,9 @@ Rails/Exit:
RSpec/NotToNot: RSpec/NotToNot:
EnforcedStyle: to_not EnforcedStyle: to_not
RSpec/Rails/HttpStatus:
EnforcedStyle: numeric
Style/HashSyntax: Style/HashSyntax:
EnforcedStyle: ruby19_no_mixed_keys EnforcedStyle: ruby19_no_mixed_keys

View File

@ -1427,148 +1427,6 @@ RSpec/PredicateMatcher:
- 'spec/models/user_spec.rb' - 'spec/models/user_spec.rb'
- 'spec/services/post_status_service_spec.rb' - 'spec/services/post_status_service_spec.rb'
# Offense count: 3
# This cop supports unsafe autocorrection (--autocorrect-all).
RSpec/Rails/HaveHttpStatus:
Exclude:
- 'spec/controllers/settings/applications_controller_spec.rb'
- 'spec/requests/catch_all_route_request_spec.rb'
# Offense count: 432
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: numeric, symbolic
RSpec/Rails/HttpStatus:
Exclude:
- 'spec/controllers/about_controller_spec.rb'
- 'spec/controllers/accounts_controller_spec.rb'
- 'spec/controllers/activitypub/collections_controller_spec.rb'
- 'spec/controllers/activitypub/followers_synchronizations_controller_spec.rb'
- 'spec/controllers/activitypub/inboxes_controller_spec.rb'
- 'spec/controllers/activitypub/outboxes_controller_spec.rb'
- 'spec/controllers/activitypub/replies_controller_spec.rb'
- 'spec/controllers/admin/accounts_controller_spec.rb'
- 'spec/controllers/admin/action_logs_controller_spec.rb'
- 'spec/controllers/admin/change_email_controller_spec.rb'
- 'spec/controllers/admin/confirmations_controller_spec.rb'
- 'spec/controllers/admin/custom_emojis_controller_spec.rb'
- 'spec/controllers/admin/dashboard_controller_spec.rb'
- 'spec/controllers/admin/domain_allows_controller_spec.rb'
- 'spec/controllers/admin/domain_blocks_controller_spec.rb'
- 'spec/controllers/admin/email_domain_blocks_controller_spec.rb'
- 'spec/controllers/admin/export_domain_allows_controller_spec.rb'
- 'spec/controllers/admin/export_domain_blocks_controller_spec.rb'
- 'spec/controllers/admin/instances_controller_spec.rb'
- 'spec/controllers/admin/reports/actions_controller_spec.rb'
- 'spec/controllers/admin/reports_controller_spec.rb'
- 'spec/controllers/admin/settings/branding_controller_spec.rb'
- 'spec/controllers/admin/statuses_controller_spec.rb'
- 'spec/controllers/admin/tags_controller_spec.rb'
- 'spec/controllers/api/base_controller_spec.rb'
- 'spec/controllers/api/oembed_controller_spec.rb'
- 'spec/controllers/api/v1/accounts/credentials_controller_spec.rb'
- 'spec/controllers/api/v1/accounts/follower_accounts_controller_spec.rb'
- 'spec/controllers/api/v1/accounts/following_accounts_controller_spec.rb'
- 'spec/controllers/api/v1/accounts/lists_controller_spec.rb'
- 'spec/controllers/api/v1/accounts/notes_controller_spec.rb'
- 'spec/controllers/api/v1/accounts/pins_controller_spec.rb'
- 'spec/controllers/api/v1/accounts/relationships_controller_spec.rb'
- 'spec/controllers/api/v1/accounts/search_controller_spec.rb'
- 'spec/controllers/api/v1/accounts_controller_spec.rb'
- 'spec/controllers/api/v1/admin/account_actions_controller_spec.rb'
- 'spec/controllers/api/v1/admin/accounts_controller_spec.rb'
- 'spec/controllers/api/v1/admin/domain_allows_controller_spec.rb'
- 'spec/controllers/api/v1/admin/domain_blocks_controller_spec.rb'
- 'spec/controllers/api/v1/admin/reports_controller_spec.rb'
- 'spec/controllers/api/v1/announcements/reactions_controller_spec.rb'
- 'spec/controllers/api/v1/announcements_controller_spec.rb'
- 'spec/controllers/api/v1/apps/credentials_controller_spec.rb'
- 'spec/controllers/api/v1/apps_controller_spec.rb'
- 'spec/controllers/api/v1/blocks_controller_spec.rb'
- 'spec/controllers/api/v1/conversations_controller_spec.rb'
- 'spec/controllers/api/v1/custom_emojis_controller_spec.rb'
- 'spec/controllers/api/v1/domain_blocks_controller_spec.rb'
- 'spec/controllers/api/v1/endorsements_controller_spec.rb'
- 'spec/controllers/api/v1/filters_controller_spec.rb'
- 'spec/controllers/api/v1/follow_requests_controller_spec.rb'
- 'spec/controllers/api/v1/instances/activity_controller_spec.rb'
- 'spec/controllers/api/v1/instances/peers_controller_spec.rb'
- 'spec/controllers/api/v1/instances_controller_spec.rb'
- 'spec/controllers/api/v1/lists/accounts_controller_spec.rb'
- 'spec/controllers/api/v1/lists_controller_spec.rb'
- 'spec/controllers/api/v1/markers_controller_spec.rb'
- 'spec/controllers/api/v1/media_controller_spec.rb'
- 'spec/controllers/api/v1/mutes_controller_spec.rb'
- 'spec/controllers/api/v1/notifications_controller_spec.rb'
- 'spec/controllers/api/v1/polls/votes_controller_spec.rb'
- 'spec/controllers/api/v1/polls_controller_spec.rb'
- 'spec/controllers/api/v1/reports_controller_spec.rb'
- 'spec/controllers/api/v1/statuses/bookmarks_controller_spec.rb'
- 'spec/controllers/api/v1/statuses/favourited_by_accounts_controller_spec.rb'
- 'spec/controllers/api/v1/statuses/favourites_controller_spec.rb'
- 'spec/controllers/api/v1/statuses/histories_controller_spec.rb'
- 'spec/controllers/api/v1/statuses/mutes_controller_spec.rb'
- 'spec/controllers/api/v1/statuses/pins_controller_spec.rb'
- 'spec/controllers/api/v1/statuses/reblogged_by_accounts_controller_spec.rb'
- 'spec/controllers/api/v1/statuses/reblogs_controller_spec.rb'
- 'spec/controllers/api/v1/statuses/sources_controller_spec.rb'
- 'spec/controllers/api/v1/statuses_controller_spec.rb'
- 'spec/controllers/api/v1/streaming_controller_spec.rb'
- 'spec/controllers/api/v1/suggestions_controller_spec.rb'
- 'spec/controllers/api/v1/timelines/home_controller_spec.rb'
- 'spec/controllers/api/v1/timelines/list_controller_spec.rb'
- 'spec/controllers/api/v1/timelines/public_controller_spec.rb'
- 'spec/controllers/api/v1/timelines/tag_controller_spec.rb'
- 'spec/controllers/api/v1/trends/tags_controller_spec.rb'
- 'spec/controllers/api/v2/admin/accounts_controller_spec.rb'
- 'spec/controllers/api/v2/filters/keywords_controller_spec.rb'
- 'spec/controllers/api/v2/filters/statuses_controller_spec.rb'
- 'spec/controllers/api/v2/filters_controller_spec.rb'
- 'spec/controllers/api/v2/search_controller_spec.rb'
- 'spec/controllers/api/web/settings_controller_spec.rb'
- 'spec/controllers/application_controller_spec.rb'
- 'spec/controllers/auth/confirmations_controller_spec.rb'
- 'spec/controllers/auth/passwords_controller_spec.rb'
- 'spec/controllers/auth/registrations_controller_spec.rb'
- 'spec/controllers/auth/sessions_controller_spec.rb'
- 'spec/controllers/authorize_interactions_controller_spec.rb'
- 'spec/controllers/concerns/account_controller_concern_spec.rb'
- 'spec/controllers/concerns/export_controller_concern_spec.rb'
- 'spec/controllers/concerns/signature_verification_spec.rb'
- 'spec/controllers/emojis_controller_spec.rb'
- 'spec/controllers/follower_accounts_controller_spec.rb'
- 'spec/controllers/following_accounts_controller_spec.rb'
- 'spec/controllers/instance_actors_controller_spec.rb'
- 'spec/controllers/intents_controller_spec.rb'
- 'spec/controllers/invites_controller_spec.rb'
- 'spec/controllers/manifests_controller_spec.rb'
- 'spec/controllers/media_controller_spec.rb'
- 'spec/controllers/media_proxy_controller_spec.rb'
- 'spec/controllers/oauth/authorizations_controller_spec.rb'
- 'spec/controllers/oauth/authorized_applications_controller_spec.rb'
- 'spec/controllers/relationships_controller_spec.rb'
- 'spec/controllers/settings/applications_controller_spec.rb'
- 'spec/controllers/settings/deletes_controller_spec.rb'
- 'spec/controllers/settings/exports_controller_spec.rb'
- 'spec/controllers/settings/imports_controller_spec.rb'
- 'spec/controllers/settings/migrations_controller_spec.rb'
- 'spec/controllers/settings/preferences/notifications_controller_spec.rb'
- 'spec/controllers/settings/preferences/other_controller_spec.rb'
- 'spec/controllers/settings/profiles_controller_spec.rb'
- 'spec/controllers/settings/two_factor_authentication/confirmations_controller_spec.rb'
- 'spec/controllers/settings/two_factor_authentication/otp_authentication_controller_spec.rb'
- 'spec/controllers/settings/two_factor_authentication/recovery_codes_controller_spec.rb'
- 'spec/controllers/settings/two_factor_authentication/webauthn_credentials_controller_spec.rb'
- 'spec/controllers/settings/two_factor_authentication_methods_controller_spec.rb'
- 'spec/controllers/statuses_cleanup_controller_spec.rb'
- 'spec/controllers/statuses_controller_spec.rb'
- 'spec/controllers/tags_controller_spec.rb'
- 'spec/controllers/well_known/host_meta_controller_spec.rb'
- 'spec/controllers/well_known/nodeinfo_controller_spec.rb'
- 'spec/controllers/well_known/webfinger_controller_spec.rb'
- 'spec/requests/host_meta_request_spec.rb'
- 'spec/requests/webfinger_request_spec.rb'
# Offense count: 180 # Offense count: 180
# This cop supports unsafe autocorrection (--autocorrect-all). # This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: Inferences. # Configuration parameters: Inferences.
@ -2159,35 +2017,6 @@ Rails/HttpPositionalArguments:
Exclude: Exclude:
- 'spec/config/initializers/rack_attack_spec.rb' - 'spec/config/initializers/rack_attack_spec.rb'
# Offense count: 49
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: numeric, symbolic
Rails/HttpStatus:
Exclude:
- 'app/controllers/activitypub/inboxes_controller.rb'
- 'app/controllers/api/base_controller.rb'
- 'app/controllers/api/v1/admin/domain_blocks_controller.rb'
- 'app/controllers/api/v1/instances/activity_controller.rb'
- 'app/controllers/api/v1/instances/domain_blocks_controller.rb'
- 'app/controllers/api/v1/instances/peers_controller.rb'
- 'app/controllers/api/v1/lists_controller.rb'
- 'app/controllers/api/v1/markers_controller.rb'
- 'app/controllers/api/v1/media_controller.rb'
- 'app/controllers/api/v1/statuses_controller.rb'
- 'app/controllers/api/v1/streaming_controller.rb'
- 'app/controllers/api/v2/media_controller.rb'
- 'app/controllers/api/v2/search_controller.rb'
- 'app/controllers/api/web/base_controller.rb'
- 'app/controllers/settings/pictures_controller.rb'
- 'app/controllers/well_known/webfinger_controller.rb'
- 'spec/controllers/api/base_controller_spec.rb'
- 'spec/controllers/application_controller_spec.rb'
- 'spec/controllers/concerns/account_controller_concern_spec.rb'
- 'spec/controllers/concerns/localized_spec.rb'
- 'spec/controllers/concerns/rate_limit_headers_spec.rb'
- 'spec/controllers/concerns/signature_verification_spec.rb'
# Offense count: 7 # Offense count: 7
# Configuration parameters: Include. # Configuration parameters: Include.
# Include: spec/**/*.rb, test/**/*.rb # Include: spec/**/*.rb, test/**/*.rb

View File

@ -30,7 +30,7 @@ class Api::V1::AccountsController < Api::BaseController
self.response_body = Oj.dump(response.body) self.response_body = Oj.dump(response.body)
self.status = response.status self.status = response.status
rescue ActiveRecord::RecordInvalid => e rescue ActiveRecord::RecordInvalid => e
render json: ValidationErrorFormatter.new(e, 'account.username': :username, 'invite_request.text': :reason).as_json, status: :unprocessable_entity render json: ValidationErrorFormatter.new(e, 'account.username': :username, 'invite_request.text': :reason).as_json, status: 422
end end
def follow def follow

View File

@ -15,10 +15,10 @@ class Api::V1::Emails::ConfirmationsController < Api::BaseController
private private
def require_user_owned_by_application! def require_user_owned_by_application!
render json: { error: 'This method is only available to the application the user originally signed-up with' }, status: :forbidden unless current_user && current_user.created_by_application_id == doorkeeper_token.application_id render json: { error: 'This method is only available to the application the user originally signed-up with' }, status: 403 unless current_user && current_user.created_by_application_id == doorkeeper_token.application_id
end end
def require_user_not_confirmed! def require_user_not_confirmed!
render json: { error: 'This method is only available while the e-mail is awaiting confirmation' }, status: :forbidden unless !current_user.confirmed? || current_user.unconfirmed_email.present? render json: { error: 'This method is only available while the e-mail is awaiting confirmation' }, status: 403 unless !current_user.confirmed? || current_user.unconfirmed_email.present?
end end
end end

View File

@ -52,9 +52,9 @@ class Auth::SessionsController < Devise::SessionsController
session[:webauthn_challenge] = options_for_get.challenge session[:webauthn_challenge] = options_for_get.challenge
render json: options_for_get, status: :ok render json: options_for_get, status: 200
else else
render json: { error: t('webauthn_credentials.not_enabled') }, status: :unauthorized render json: { error: t('webauthn_credentials.not_enabled') }, status: 401
end end
end end

View File

@ -57,10 +57,10 @@ module TwoFactorAuthenticationConcern
if valid_webauthn_credential?(user, webauthn_credential) if valid_webauthn_credential?(user, webauthn_credential)
on_authentication_success(user, :webauthn) on_authentication_success(user, :webauthn)
render json: { redirect_path: after_sign_in_path_for(user) }, status: :ok render json: { redirect_path: after_sign_in_path_for(user) }, status: 200
else else
on_authentication_failure(user, :webauthn, :invalid_credential) on_authentication_failure(user, :webauthn, :invalid_credential)
render json: { error: t('webauthn_credentials.invalid_credential') }, status: :unprocessable_entity render json: { error: t('webauthn_credentials.invalid_credential') }, status: 422
end end
end end

View File

@ -27,7 +27,7 @@ module Settings
session[:webauthn_challenge] = options_for_create.challenge session[:webauthn_challenge] = options_for_create.challenge
render json: options_for_create, status: :ok render json: options_for_create, status: 200
end end
def create def create

View File

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

View File

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

View File

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

View File

@ -18,7 +18,7 @@ describe Admin::RolesController do
context 'when user does not have permission to manage roles' do context 'when user does not have permission to manage roles' do
it 'returns http forbidden' do it 'returns http forbidden' do
expect(response).to have_http_status(:forbidden) expect(response).to have_http_status(403)
end end
end end
@ -38,7 +38,7 @@ describe Admin::RolesController do
context 'when user does not have permission to manage roles' do context 'when user does not have permission to manage roles' do
it 'returns http forbidden' do it 'returns http forbidden' do
expect(response).to have_http_status(:forbidden) expect(response).to have_http_status(403)
end end
end end
@ -128,7 +128,7 @@ describe Admin::RolesController do
context 'when user does not have permission to manage roles' do context 'when user does not have permission to manage roles' do
it 'returns http forbidden' do it 'returns http forbidden' do
expect(response).to have_http_status(:forbidden) expect(response).to have_http_status(403)
end end
end end
@ -145,7 +145,7 @@ describe Admin::RolesController do
let(:role_position) { current_role.position + 1 } let(:role_position) { current_role.position + 1 }
it 'returns http forbidden' do it 'returns http forbidden' do
expect(response).to have_http_status(:forbidden) expect(response).to have_http_status(403)
end end
end end
end end
@ -165,7 +165,7 @@ describe Admin::RolesController do
context 'when user does not have permission to manage roles' do context 'when user does not have permission to manage roles' do
it 'returns http forbidden' do it 'returns http forbidden' do
expect(response).to have_http_status(:forbidden) expect(response).to have_http_status(403)
end end
it 'does not update the role' do it 'does not update the role' do
@ -203,7 +203,7 @@ describe Admin::RolesController do
let(:role_position) { current_role.position + 1 } let(:role_position) { current_role.position + 1 }
it 'returns http forbidden' do it 'returns http forbidden' do
expect(response).to have_http_status(:forbidden) expect(response).to have_http_status(403)
end end
it 'does not update the role' do 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 context 'when user does not have permission to manage roles' do
it 'returns http forbidden' do it 'returns http forbidden' do
expect(response).to have_http_status(:forbidden) expect(response).to have_http_status(403)
end end
end end
@ -241,7 +241,7 @@ describe Admin::RolesController do
let(:role_position) { current_role.position + 1 } let(:role_position) { current_role.position + 1 }
it 'returns http forbidden' do it 'returns http forbidden' do
expect(response).to have_http_status(:forbidden) expect(response).to have_http_status(403)
end end
end 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) } let(:previous_role) { UserRole.create(name: 'Baz', permissions: UserRole::FLAGS[:administrator], position: 100) }
it 'returns http forbidden' do it 'returns http forbidden' do
expect(response).to have_http_status(:forbidden) expect(response).to have_http_status(403)
end end
end end
end end
@ -74,7 +74,7 @@ describe Admin::Users::RolesController do
end end
it 'returns http forbidden' do it 'returns http forbidden' do
expect(response).to have_http_status(:forbidden) expect(response).to have_http_status(403)
end end
end end
end end

View File

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

View File

@ -16,7 +16,7 @@ describe Api::V1::Accounts::StatusesController do
it 'returns http success' do it 'returns http success' do
get :index, params: { account_id: user.account.id, limit: 1 } 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 end
it 'returns expected headers' do it 'returns expected headers' do
@ -29,7 +29,7 @@ describe Api::V1::Accounts::StatusesController do
it 'returns http success' do it 'returns http success' do
get :index, params: { account_id: user.account.id, only_media: true } 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
end end
@ -44,7 +44,7 @@ describe Api::V1::Accounts::StatusesController do
end end
it 'returns http success' do it 'returns http success' do
expect(response).to have_http_status(:ok) expect(response).to have_http_status(200)
end end
it 'returns posts along with self replies' do it 'returns posts along with self replies' do
@ -63,7 +63,7 @@ describe Api::V1::Accounts::StatusesController do
it 'returns http success' do it 'returns http success' do
get :index, params: { account_id: user.account.id, pinned: true } 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
end end
@ -79,7 +79,7 @@ describe Api::V1::Accounts::StatusesController do
it 'returns http success' do it 'returns http success' do
get :index, params: { account_id: account.id, pinned: true } get :index, params: { account_id: account.id, pinned: true }
expect(response).to have_http_status(:ok) expect(response).to have_http_status(200)
end end
context 'when user does not follow account' do 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 context 'without token' do
it 'returns http unauthorized' do it 'returns http unauthorized' do
put :update, params: { announcement_id: announcement.id, id: '😂' } put :update, params: { announcement_id: announcement.id, id: '😂' }
expect(response).to have_http_status :unauthorized expect(response).to have_http_status 401
end end
end end
@ -43,7 +43,7 @@ RSpec.describe Api::V1::Announcements::ReactionsController, type: :controller do
context 'without token' do context 'without token' do
it 'returns http unauthorized' do it 'returns http unauthorized' do
delete :destroy, params: { announcement_id: announcement.id, id: '😂' } delete :destroy, params: { announcement_id: announcement.id, id: '😂' }
expect(response).to have_http_status :unauthorized expect(response).to have_http_status 401
end end
end end

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -36,7 +36,7 @@ describe Api::V1::Timelines::ListController do
describe 'GET #show' do describe 'GET #show' do
it 'returns http not found' do it 'returns http not found' do
get :show, params: { id: list.id } get :show, params: { id: list.id }
expect(response).to have_http_status(:not_found) expect(response).to have_http_status(404)
end end
end end
end end
@ -48,7 +48,7 @@ describe Api::V1::Timelines::ListController do
it 'returns http unprocessable entity' do it 'returns http unprocessable entity' do
get :show, params: { id: list.id } 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 expect(response.headers['Link']).to be_nil
end end
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}" } let(:url) { "http://#{Rails.configuration.x.web_domain}/@#{status.account.username}/#{status.id}" }
it 'returns a right response' do 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 expect(body[:author_name]).to eq status.account.username
end end
end end
@ -37,7 +37,7 @@ describe Api::Web::EmbedsController do
let(:call_result) { { result: :ok } } let(:call_result) { { result: :ok } }
it 'returns a right response' do 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' expect(body[:result]).to eq 'ok'
end end
end end
@ -46,7 +46,7 @@ describe Api::Web::EmbedsController do
let(:call_result) { nil } let(:call_result) { nil }
it 'returns a right response' do it 'returns a right response' do
expect(response).to have_http_status :not_found expect(response).to have_http_status 404
end end
end end
end end

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -24,7 +24,7 @@ describe Settings::SessionsController do
let(:id) { session_activation.id + 1000 } let(:id) { session_activation.id + 1000 }
it 'destroys session activation' do it 'destroys session activation' do
is_expected.to have_http_status :not_found is_expected.to have_http_status 404
end end
end 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' } } before { get :show, params: { title: 'test title', text: 'test text', url: 'url1 url2' } }
it 'returns http success' do 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' expect(body_classes).to eq 'modal-layout compose-standalone'
end end
end end

View File

@ -5,7 +5,7 @@ describe 'The catch all route' do
it 'returns a 404 page as html' do it 'returns a 404 page as html' do
get '/test' get '/test'
expect(response.status).to eq 404 expect(response).to have_http_status 404
expect(response.media_type).to eq 'text/html' expect(response.media_type).to eq 'text/html'
end end
end end
@ -14,7 +14,7 @@ describe 'The catch all route' do
it 'returns a 404 page as html' do it 'returns a 404 page as html' do
get '/test.test' get '/test.test'
expect(response.status).to eq 404 expect(response).to have_http_status 404
expect(response.media_type).to eq 'text/html' expect(response.media_type).to eq 'text/html'
end end
end end