From 190e204decaba9c14f5a5997d243ed007f68b2a1 Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Sun, 17 Nov 2019 12:06:19 +0000 Subject: [PATCH] Add latest changes from gitlab-org/gitlab@master --- .rubocop_todo.yml | 7 ------- app/controllers/admin/applications_controller.rb | 2 +- app/controllers/admin/groups_controller.rb | 2 +- app/controllers/admin/identities_controller.rb | 4 ++-- app/controllers/admin/keys_controller.rb | 4 ++-- app/controllers/admin/labels_controller.rb | 2 +- app/controllers/admin/projects_controller.rb | 2 +- app/controllers/admin/spam_logs_controller.rb | 2 +- app/controllers/admin/users_controller.rb | 2 +- app/controllers/application_controller.rb | 8 ++++---- app/controllers/concerns/lfs_request.rb | 4 ++-- app/controllers/dashboard/todos_controller.rb | 4 ++-- app/controllers/groups/labels_controller.rb | 2 +- app/controllers/groups_controller.rb | 2 +- app/controllers/help_controller.rb | 2 +- app/controllers/oauth/applications_controller.rb | 2 +- .../oauth/authorized_applications_controller.rb | 2 +- app/controllers/omniauth_callbacks_controller.rb | 2 +- app/controllers/profiles/u2f_registrations_controller.rb | 2 +- app/controllers/projects/labels_controller.rb | 2 +- app/controllers/projects/lfs_api_controller.rb | 2 +- app/controllers/projects/pages_controller.rb | 2 +- app/controllers/projects/pages_domains_controller.rb | 4 ++-- app/controllers/projects/tags_controller.rb | 2 +- app/controllers/projects/wikis_controller.rb | 2 +- app/controllers/projects_controller.rb | 2 +- app/controllers/registrations_controller.rb | 4 ++-- spec/controllers/application_controller_spec.rb | 6 +++--- 28 files changed, 38 insertions(+), 45 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 3ed7af71b4f..f0388ab79d2 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -401,13 +401,6 @@ Rails/FilePath: Rails/HasManyOrHasOneDependent: Enabled: false -# Offense count: 40 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle. -# SupportedStyles: numeric, symbolic -Rails/HttpStatus: - Enabled: false - # Offense count: 2 # Configuration parameters: Include. # Include: app/controllers/**/*.rb diff --git a/app/controllers/admin/applications_controller.rb b/app/controllers/admin/applications_controller.rb index 22e629ccf59..907b295870d 100644 --- a/app/controllers/admin/applications_controller.rb +++ b/app/controllers/admin/applications_controller.rb @@ -44,7 +44,7 @@ class Admin::ApplicationsController < Admin::ApplicationController def destroy @application.destroy - redirect_to admin_applications_url, status: 302, notice: _('Application was successfully destroyed.') + redirect_to admin_applications_url, status: :found, notice: _('Application was successfully destroyed.') end private diff --git a/app/controllers/admin/groups_controller.rb b/app/controllers/admin/groups_controller.rb index 85a37fcd43e..5455cefdc8e 100644 --- a/app/controllers/admin/groups_controller.rb +++ b/app/controllers/admin/groups_controller.rb @@ -69,7 +69,7 @@ class Admin::GroupsController < Admin::ApplicationController Groups::DestroyService.new(@group, current_user).async_execute redirect_to admin_groups_path, - status: 302, + status: :found, alert: _('Group %{group_name} was scheduled for deletion.') % { group_name: @group.name } end diff --git a/app/controllers/admin/identities_controller.rb b/app/controllers/admin/identities_controller.rb index f518f7a657f..8f2e34a6294 100644 --- a/app/controllers/admin/identities_controller.rb +++ b/app/controllers/admin/identities_controller.rb @@ -38,9 +38,9 @@ class Admin::IdentitiesController < Admin::ApplicationController def destroy if @identity.destroy RepairLdapBlockedUserService.new(@user).execute - redirect_to admin_user_identities_path(@user), status: 302, notice: _('User identity was successfully removed.') + redirect_to admin_user_identities_path(@user), status: :found, notice: _('User identity was successfully removed.') else - redirect_to admin_user_identities_path(@user), status: 302, alert: _('Failed to remove user identity.') + redirect_to admin_user_identities_path(@user), status: :found, alert: _('Failed to remove user identity.') end end diff --git a/app/controllers/admin/keys_controller.rb b/app/controllers/admin/keys_controller.rb index 340eecd7632..58ea19d1210 100644 --- a/app/controllers/admin/keys_controller.rb +++ b/app/controllers/admin/keys_controller.rb @@ -17,9 +17,9 @@ class Admin::KeysController < Admin::ApplicationController respond_to do |format| if key.destroy - format.html { redirect_to keys_admin_user_path(user), status: 302, notice: _('User key was successfully removed.') } + format.html { redirect_to keys_admin_user_path(user), status: :found, notice: _('User key was successfully removed.') } else - format.html { redirect_to keys_admin_user_path(user), status: 302, alert: _('Failed to remove user key.') } + format.html { redirect_to keys_admin_user_path(user), status: :found, alert: _('Failed to remove user key.') } end end end diff --git a/app/controllers/admin/labels_controller.rb b/app/controllers/admin/labels_controller.rb index 90c1694fd2e..6cb206c1686 100644 --- a/app/controllers/admin/labels_controller.rb +++ b/app/controllers/admin/labels_controller.rb @@ -43,7 +43,7 @@ class Admin::LabelsController < Admin::ApplicationController respond_to do |format| format.html do - redirect_to admin_labels_path, status: 302, notice: _('Label was removed') + redirect_to admin_labels_path, status: :found, notice: _('Label was removed') end format.js end diff --git a/app/controllers/admin/projects_controller.rb b/app/controllers/admin/projects_controller.rb index 0e8c69eb7d6..cdedc34e634 100644 --- a/app/controllers/admin/projects_controller.rb +++ b/app/controllers/admin/projects_controller.rb @@ -41,7 +41,7 @@ class Admin::ProjectsController < Admin::ApplicationController redirect_to admin_projects_path, status: :found rescue Projects::DestroyService::DestroyError => ex - redirect_to admin_projects_path, status: 302, alert: ex.message + redirect_to admin_projects_path, status: :found, alert: ex.message end # rubocop: disable CodeReuse/ActiveRecord diff --git a/app/controllers/admin/spam_logs_controller.rb b/app/controllers/admin/spam_logs_controller.rb index 45cf0d3207e..a41d8a22650 100644 --- a/app/controllers/admin/spam_logs_controller.rb +++ b/app/controllers/admin/spam_logs_controller.rb @@ -13,7 +13,7 @@ class Admin::SpamLogsController < Admin::ApplicationController if params[:remove_user] spam_log.remove_user(deleted_by: current_user) redirect_to admin_spam_logs_path, - status: 302, + status: :found, notice: _('User %{username} was successfully removed.') % { username: spam_log.user.username } else spam_log.destroy diff --git a/app/controllers/admin/users_controller.rb b/app/controllers/admin/users_controller.rb index 4c1ac8f206a..9fbfc59f630 100644 --- a/app/controllers/admin/users_controller.rb +++ b/app/controllers/admin/users_controller.rb @@ -169,7 +169,7 @@ class Admin::UsersController < Admin::ApplicationController user.delete_async(deleted_by: current_user, params: params.permit(:hard_delete)) respond_to do |format| - format.html { redirect_to admin_users_path, status: 302, notice: _("The user is being deleted.") } + format.html { redirect_to admin_users_path, status: :found, notice: _("The user is being deleted.") } format.json { head :ok } end end diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index e4d878641b3..4d55d7f00f0 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -58,7 +58,7 @@ class ApplicationController < ActionController::Base rescue_from Encoding::CompatibilityError do |exception| log_exception(exception) - render "errors/encoding", layout: "errors", status: 500 + render "errors/encoding", layout: "errors", status: :internal_server_error end rescue_from ActiveRecord::RecordNotFound do |exception| @@ -197,19 +197,19 @@ class ApplicationController < ActionController::Base end def git_not_found! - render "errors/git_not_found.html", layout: "errors", status: 404 + render "errors/git_not_found.html", layout: "errors", status: :not_found end def render_403 respond_to do |format| format.any { head :forbidden } - format.html { render "errors/access_denied", layout: "errors", status: 403 } + format.html { render "errors/access_denied", layout: "errors", status: :forbidden } end end def render_404 respond_to do |format| - format.html { render "errors/not_found", layout: "errors", status: 404 } + format.html { render "errors/not_found", layout: "errors", status: :not_found } # Prevent the Rails CSRF protector from thinking a missing .js file is a JavaScript file format.js { render json: '', status: :not_found, content_type: 'application/json' } format.any { head :not_found } diff --git a/app/controllers/concerns/lfs_request.rb b/app/controllers/concerns/lfs_request.rb index 417bb169f39..61072eec535 100644 --- a/app/controllers/concerns/lfs_request.rb +++ b/app/controllers/concerns/lfs_request.rb @@ -56,7 +56,7 @@ module LfsRequest documentation_url: help_url }, content_type: CONTENT_TYPE, - status: 403 + status: :forbidden ) end @@ -67,7 +67,7 @@ module LfsRequest documentation_url: help_url }, content_type: CONTENT_TYPE, - status: 404 + status: :not_found ) end diff --git a/app/controllers/dashboard/todos_controller.rb b/app/controllers/dashboard/todos_controller.rb index 80c0a0d88a8..ebee8e9094e 100644 --- a/app/controllers/dashboard/todos_controller.rb +++ b/app/controllers/dashboard/todos_controller.rb @@ -22,7 +22,7 @@ class Dashboard::TodosController < Dashboard::ApplicationController respond_to do |format| format.html do redirect_to dashboard_todos_path, - status: 302, + status: :found, notice: _('To-do item successfully marked as done.') end format.js { head :ok } @@ -34,7 +34,7 @@ class Dashboard::TodosController < Dashboard::ApplicationController updated_ids = TodoService.new.mark_todos_as_done(@todos, current_user) respond_to do |format| - format.html { redirect_to dashboard_todos_path, status: 302, notice: _('Everything on your to-do list is marked as done.') } + format.html { redirect_to dashboard_todos_path, status: :found, notice: _('Everything on your to-do list is marked as done.') } format.js { head :ok } format.json { render json: todos_counts.merge(updated_ids: updated_ids) } end diff --git a/app/controllers/groups/labels_controller.rb b/app/controllers/groups/labels_controller.rb index 26768c628ca..1034ca6cd7b 100644 --- a/app/controllers/groups/labels_controller.rb +++ b/app/controllers/groups/labels_controller.rb @@ -63,7 +63,7 @@ class Groups::LabelsController < Groups::ApplicationController respond_to do |format| format.html do - redirect_to group_labels_path(@group), status: 302, notice: "#{@label.name} deleted permanently" + redirect_to group_labels_path(@group), status: :found, notice: "#{@label.name} deleted permanently" end format.js end diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb index bc02e8ba504..755d97b091c 100644 --- a/app/controllers/groups_controller.rb +++ b/app/controllers/groups_controller.rb @@ -116,7 +116,7 @@ class GroupsController < Groups::ApplicationController def destroy Groups::DestroyService.new(@group, current_user).async_execute - redirect_to root_path, status: 302, alert: "Group '#{@group.name}' was scheduled for deletion." + redirect_to root_path, status: :found, alert: "Group '#{@group.name}' was scheduled for deletion." end # rubocop: disable CodeReuse/ActiveRecord diff --git a/app/controllers/help_controller.rb b/app/controllers/help_controller.rb index a58235790ad..97895d6461c 100644 --- a/app/controllers/help_controller.rb +++ b/app/controllers/help_controller.rb @@ -36,7 +36,7 @@ class HelpController < ApplicationController render 'show.html.haml' else # Force template to Haml - render 'errors/not_found.html.haml', layout: 'errors', status: 404 + render 'errors/not_found.html.haml', layout: 'errors', status: :not_found end end diff --git a/app/controllers/oauth/applications_controller.rb b/app/controllers/oauth/applications_controller.rb index 12dc2d1af1c..8dd51ce1d64 100644 --- a/app/controllers/oauth/applications_controller.rb +++ b/app/controllers/oauth/applications_controller.rb @@ -57,7 +57,7 @@ class Oauth::ApplicationsController < Doorkeeper::ApplicationsController end rescue_from ActiveRecord::RecordNotFound do |exception| - render "errors/not_found", layout: "errors", status: 404 + render "errors/not_found", layout: "errors", status: :not_found end def create_application_params diff --git a/app/controllers/oauth/authorized_applications_controller.rb b/app/controllers/oauth/authorized_applications_controller.rb index a59ade559b3..9cfa57c53a5 100644 --- a/app/controllers/oauth/authorized_applications_controller.rb +++ b/app/controllers/oauth/authorized_applications_controller.rb @@ -13,7 +13,7 @@ class Oauth::AuthorizedApplicationsController < Doorkeeper::AuthorizedApplicatio end redirect_to applications_profile_url, - status: 302, + status: :found, notice: I18n.t(:notice, scope: [:doorkeeper, :flash, :authorized_applications, :destroy]) end end diff --git a/app/controllers/omniauth_callbacks_controller.rb b/app/controllers/omniauth_callbacks_controller.rb index b992972dfb8..eca58748cc5 100644 --- a/app/controllers/omniauth_callbacks_controller.rb +++ b/app/controllers/omniauth_callbacks_controller.rb @@ -47,7 +47,7 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController def omniauth_error @provider = params[:provider] @error = params[:error] - render 'errors/omniauth_error', layout: "oauth_error", status: 422 + render 'errors/omniauth_error', layout: "oauth_error", status: :unprocessable_entity end def cas3 diff --git a/app/controllers/profiles/u2f_registrations_controller.rb b/app/controllers/profiles/u2f_registrations_controller.rb index 866c4dee6e2..84ce4a56e64 100644 --- a/app/controllers/profiles/u2f_registrations_controller.rb +++ b/app/controllers/profiles/u2f_registrations_controller.rb @@ -4,6 +4,6 @@ class Profiles::U2fRegistrationsController < Profiles::ApplicationController def destroy u2f_registration = current_user.u2f_registrations.find(params[:id]) u2f_registration.destroy - redirect_to profile_two_factor_auth_path, status: 302, notice: _("Successfully deleted U2F device.") + redirect_to profile_two_factor_auth_path, status: :found, notice: _("Successfully deleted U2F device.") end end diff --git a/app/controllers/projects/labels_controller.rb b/app/controllers/projects/labels_controller.rb index 386a1f00bd2..b7aeab8f5ff 100644 --- a/app/controllers/projects/labels_controller.rb +++ b/app/controllers/projects/labels_controller.rb @@ -76,7 +76,7 @@ class Projects::LabelsController < Projects::ApplicationController @labels = find_labels redirect_to project_labels_path(@project), - status: 302, + status: :found, notice: 'Label was removed' end diff --git a/app/controllers/projects/lfs_api_controller.rb b/app/controllers/projects/lfs_api_controller.rb index a1983bc5462..1273c55b83a 100644 --- a/app/controllers/projects/lfs_api_controller.rb +++ b/app/controllers/projects/lfs_api_controller.rb @@ -109,7 +109,7 @@ class Projects::LfsApiController < Projects::GitHttpClientController message: lfs_read_only_message }, content_type: LfsRequest::CONTENT_TYPE, - status: 403 + status: :forbidden ) end end diff --git a/app/controllers/projects/pages_controller.rb b/app/controllers/projects/pages_controller.rb index 73e629ab7c3..722fc30b3ff 100644 --- a/app/controllers/projects/pages_controller.rb +++ b/app/controllers/projects/pages_controller.rb @@ -21,7 +21,7 @@ class Projects::PagesController < Projects::ApplicationController respond_to do |format| format.html do redirect_to project_pages_path(@project), - status: 302, + status: :found, notice: 'Pages were removed' end end diff --git a/app/controllers/projects/pages_domains_controller.rb b/app/controllers/projects/pages_domains_controller.rb index 8f40eac5186..b693642981e 100644 --- a/app/controllers/projects/pages_domains_controller.rb +++ b/app/controllers/projects/pages_domains_controller.rb @@ -43,7 +43,7 @@ class Projects::PagesDomainsController < Projects::ApplicationController def update if @domain.update(update_params) redirect_to project_pages_path(@project), - status: 302, + status: :found, notice: 'Domain was updated' else render 'edit' @@ -56,7 +56,7 @@ class Projects::PagesDomainsController < Projects::ApplicationController respond_to do |format| format.html do redirect_to project_pages_path(@project), - status: 302, + status: :found, notice: 'Domain was removed' end format.js diff --git a/app/controllers/projects/tags_controller.rb b/app/controllers/projects/tags_controller.rb index 7d9387b1d94..c89bfd110c4 100644 --- a/app/controllers/projects/tags_controller.rb +++ b/app/controllers/projects/tags_controller.rb @@ -84,7 +84,7 @@ class Projects::TagsController < Projects::ApplicationController format.html do redirect_to project_tags_path(@project), - alert: @error, status: 303 + alert: @error, status: :see_other end format.js do diff --git a/app/controllers/projects/wikis_controller.rb b/app/controllers/projects/wikis_controller.rb index b187fdb2723..fb06299676c 100644 --- a/app/controllers/projects/wikis_controller.rb +++ b/app/controllers/projects/wikis_controller.rb @@ -110,7 +110,7 @@ class Projects::WikisController < Projects::ApplicationController WikiPages::DestroyService.new(@project, current_user).execute(@page) redirect_to project_wiki_path(@project, :home), - status: 302, + status: :found, notice: _("Page was successfully deleted") rescue Gitlab::Git::Wiki::OperationError => e @error = e diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index d04801bcfe7..e5dea031bb5 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -154,7 +154,7 @@ class ProjectsController < Projects::ApplicationController redirect_to dashboard_projects_path, status: :found rescue Projects::DestroyService::DestroyError => ex - redirect_to edit_project_path(@project), status: 302, alert: ex.message + redirect_to edit_project_path(@project), status: :found, alert: ex.message end def new_issuable_address diff --git a/app/controllers/registrations_controller.rb b/app/controllers/registrations_controller.rb index 84011e7643d..5fc7f5c84f0 100644 --- a/app/controllers/registrations_controller.rb +++ b/app/controllers/registrations_controller.rb @@ -45,9 +45,9 @@ class RegistrationsController < Devise::RegistrationsController if destroy_confirmation_valid? current_user.delete_async(deleted_by: current_user) session.try(:destroy) - redirect_to new_user_session_path, status: 303, notice: s_('Profiles|Account scheduled for removal.') + redirect_to new_user_session_path, status: :see_other, notice: s_('Profiles|Account scheduled for removal.') else - redirect_to profile_account_path, status: 303, alert: destroy_confirmation_failure_message + redirect_to profile_account_path, status: :see_other, alert: destroy_confirmation_failure_message end end diff --git a/spec/controllers/application_controller_spec.rb b/spec/controllers/application_controller_spec.rb index ca39f5dd9f2..04bbffc587f 100644 --- a/spec/controllers/application_controller_spec.rb +++ b/spec/controllers/application_controller_spec.rb @@ -637,7 +637,7 @@ describe ApplicationController do context 'given a 422 error page' do controller do def index - render 'errors/omniauth_error', layout: 'errors', status: 422 + render 'errors/omniauth_error', layout: 'errors', status: :unprocessable_entity end end @@ -651,7 +651,7 @@ describe ApplicationController do context 'given a 500 error page' do controller do def index - render 'errors/omniauth_error', layout: 'errors', status: 500 + render 'errors/omniauth_error', layout: 'errors', status: :internal_server_error end end @@ -665,7 +665,7 @@ describe ApplicationController do context 'given a 200 success page' do controller do def index - render 'errors/omniauth_error', layout: 'errors', status: 200 + render 'errors/omniauth_error', layout: 'errors', status: :ok end end