Skip to content
Snippets Groups Projects
Commit a544e46b authored by blackst0ne's avatar blackst0ne
Browse files

Add a rubocop rule to check if a method 'redirect_to' is used without...

Add a rubocop rule to check if a method 'redirect_to' is used without explicitly set 'status' in 'destroy' actions of controllers
parent 71f9c43c
No related branches found
No related tags found
No related merge requests found
Showing
with 34 additions and 24 deletions
Loading
Loading
@@ -39,7 +39,7 @@ class Admin::ApplicationsController < Admin::ApplicationController
 
def destroy
@application.destroy
redirect_to admin_applications_url, notice: 'Application was successfully destroyed.'
redirect_to admin_applications_url, status: 302, notice: 'Application was successfully destroyed.'
end
 
private
Loading
Loading
Loading
Loading
@@ -23,7 +23,7 @@ class Admin::DeployKeysController < Admin::ApplicationController
deploy_key.destroy
 
respond_to do |format|
format.html { redirect_to admin_deploy_keys_path }
format.html { redirect_to admin_deploy_keys_path, status: 302 }
format.json { head :ok }
end
end
Loading
Loading
Loading
Loading
@@ -56,7 +56,9 @@ class Admin::GroupsController < Admin::ApplicationController
def destroy
Groups::DestroyService.new(@group, current_user).async_execute
 
redirect_to admin_groups_path, alert: "Group '#{@group.name}' was scheduled for deletion."
redirect_to admin_groups_path,
status: 302,
alert: "Group '#{@group.name}' was scheduled for deletion."
end
 
private
Loading
Loading
Loading
Loading
@@ -34,7 +34,7 @@ class Admin::HooksController < Admin::ApplicationController
def destroy
hook.destroy
 
redirect_to admin_hooks_path
redirect_to admin_hooks_path, status: 302
end
 
def test
Loading
Loading
Loading
Loading
@@ -36,9 +36,9 @@ class Admin::IdentitiesController < Admin::ApplicationController
def destroy
if @identity.destroy
RepairLdapBlockedUserService.new(@user).execute
redirect_to admin_user_identities_path(@user), notice: 'User identity was successfully removed.'
redirect_to admin_user_identities_path(@user), status: 302, notice: 'User identity was successfully removed.'
else
redirect_to admin_user_identities_path(@user), alert: 'Failed to remove user identity.'
redirect_to admin_user_identities_path(@user), status: 302, alert: 'Failed to remove user identity.'
end
end
 
Loading
Loading
Loading
Loading
@@ -11,7 +11,7 @@ class Admin::ImpersonationsController < Admin::ApplicationController
 
session[:impersonator_id] = nil
 
redirect_to admin_user_path(original_user)
redirect_to admin_user_path(original_user), status: 302
end
 
private
Loading
Loading
Loading
Loading
@@ -15,9 +15,9 @@ class Admin::KeysController < Admin::ApplicationController
 
respond_to do |format|
if key.destroy
format.html { redirect_to keys_admin_user_path(user), notice: 'User key was successfully removed.' }
format.html { redirect_to keys_admin_user_path(user), status: 302, notice: 'User key was successfully removed.' }
else
format.html { redirect_to keys_admin_user_path(user), alert: 'Failed to remove user key.' }
format.html { redirect_to keys_admin_user_path(user), status: 302, alert: 'Failed to remove user key.' }
end
end
end
Loading
Loading
Loading
Loading
@@ -41,7 +41,7 @@ class Admin::LabelsController < Admin::ApplicationController
 
respond_to do |format|
format.html do
redirect_to(admin_labels_path, notice: 'Label was removed')
redirect_to admin_labels_path, status: 302, notice: 'Label was removed'
end
format.js
end
Loading
Loading
Loading
Loading
@@ -18,7 +18,7 @@ class Admin::RunnerProjectsController < Admin::ApplicationController
runner = rp.runner
rp.destroy
 
redirect_to admin_runner_path(runner)
redirect_to admin_runner_path(runner), status: 302
end
 
private
Loading
Loading
Loading
Loading
@@ -27,7 +27,7 @@ class Admin::RunnersController < Admin::ApplicationController
def destroy
@runner.destroy
 
redirect_to admin_runners_path
redirect_to admin_runners_path, status: 302
end
 
def resume
Loading
Loading
Loading
Loading
@@ -8,7 +8,9 @@ class Admin::SpamLogsController < Admin::ApplicationController
 
if params[:remove_user]
spam_log.remove_user(deleted_by: current_user)
redirect_to admin_spam_logs_path, notice: "User #{spam_log.user.username} was successfully removed."
redirect_to admin_spam_logs_path,
status: 302,
notice: "User #{spam_log.user.username} was successfully removed."
else
spam_log.destroy
head :ok
Loading
Loading
Loading
Loading
@@ -141,7 +141,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, notice: "The user is being deleted." }
format.html { redirect_to admin_users_path, status: 302, notice: "The user is being deleted." }
format.json { head :ok }
end
end
Loading
Loading
Loading
Loading
@@ -15,7 +15,11 @@ class Dashboard::TodosController < Dashboard::ApplicationController
TodoService.new.mark_todos_as_done_by_ids([params[:id]], current_user)
 
respond_to do |format|
format.html { redirect_to dashboard_todos_path, notice: 'Todo was successfully marked as done.' }
format.html do
redirect_to dashboard_todos_path,
status: 302,
notice: 'Todo was successfully marked as done.'
end
format.js { head :ok }
format.json { render json: todos_counts }
end
Loading
Loading
@@ -25,7 +29,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, notice: 'All todos were marked as done.' }
format.html { redirect_to dashboard_todos_path, status: 302, notice: 'All todos were marked as done.' }
format.js { head :ok }
format.json { render json: todos_counts.merge(updated_ids: updated_ids) }
end
Loading
Loading
Loading
Loading
@@ -5,6 +5,6 @@ class Groups::AvatarsController < Groups::ApplicationController
@group.remove_avatar!
@group.save
 
redirect_to edit_group_path(@group)
redirect_to edit_group_path(@group), status: 302
end
end
Loading
Loading
@@ -54,7 +54,7 @@ class Groups::LabelsController < Groups::ApplicationController
 
respond_to do |format|
format.html do
redirect_to group_labels_path(@group), notice: 'Label was removed'
redirect_to group_labels_path(@group), status: 302, notice: 'Label was removed'
end
format.js
end
Loading
Loading
Loading
Loading
@@ -101,7 +101,7 @@ class GroupsController < Groups::ApplicationController
def destroy
Groups::DestroyService.new(@group, current_user).async_execute
 
redirect_to root_path, alert: "Group '#{@group.name}' was scheduled for deletion."
redirect_to root_path, status: 302, alert: "Group '#{@group.name}' was scheduled for deletion."
end
 
protected
Loading
Loading
@@ -173,7 +173,7 @@ class GroupsController < Groups::ApplicationController
 
def build_canonical_path(group)
return group_path(group) if action_name == 'show' # root group path
params[:id] = group.to_param
 
url_for(params)
Loading
Loading
Loading
Loading
@@ -10,6 +10,8 @@ class Oauth::AuthorizedApplicationsController < Doorkeeper::AuthorizedApplicatio
Doorkeeper::AccessToken.revoke_all_for(params[:id], current_resource_owner)
end
 
redirect_to applications_profile_url, notice: I18n.t(:notice, scope: [:doorkeeper, :flash, :authorized_applications, :destroy])
redirect_to applications_profile_url,
status: 302,
notice: I18n.t(:notice, scope: [:doorkeeper, :flash, :authorized_applications, :destroy])
end
end
Loading
Loading
@@ -5,6 +5,6 @@ class Profiles::AvatarsController < Profiles::ApplicationController
 
@user.save
 
redirect_to profile_path
redirect_to profile_path, status: 302
end
end
Loading
Loading
@@ -39,7 +39,7 @@ class Profiles::ChatNamesController < Profiles::ApplicationController
flash[:alert] = "Could not delete chat nickname #{@chat_name.chat_name}."
end
 
redirect_to profile_chat_names_path
redirect_to profile_chat_names_path, status: 302
end
 
private
Loading
Loading
Loading
Loading
@@ -23,7 +23,7 @@ class Profiles::EmailsController < Profiles::ApplicationController
current_user.update_secondary_emails!
 
respond_to do |format|
format.html { redirect_to profile_emails_url }
format.html { redirect_to profile_emails_url, status: 302 }
format.js { head :ok }
end
end
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment