Skip to content

Commit 7ecc5d3

Browse files
authored
Merge pull request #3555 from AlchemyCMS/use-numeric-http-status-codes
Replace HTTP status code symbols with numeric codes
2 parents d1721ca + af921d3 commit 7ecc5d3

15 files changed

+24
-24
lines changed

app/controllers/alchemy/admin/attachments_controller.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,13 @@ def show
5252

5353
def create
5454
@attachment = Attachment.create(attachment_attributes)
55-
handle_uploader_response(status: :created)
55+
handle_uploader_response(status: 201)
5656
end
5757

5858
def update
5959
@attachment.update(attachment_attributes)
6060
if attachment_attributes["file"].present?
61-
handle_uploader_response(status: :accepted)
61+
handle_uploader_response(status: 202)
6262
else
6363
render_errors_or_redirect(
6464
@attachment,

app/controllers/alchemy/admin/base_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ def render_errors_or_redirect(object, redirect_url, flash_notice)
111111
do_redirect_to redirect_url
112112
else
113113
render action: ((params[:action] == "update") ? "edit" : "new"),
114-
status: :unprocessable_entity
114+
status: 422
115115
end
116116
end
117117

app/controllers/alchemy/admin/elements_controller.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@ def create
4141
end
4242
end
4343
if @element.save
44-
render :create, status: :created
44+
render :create, status: 201
4545
else
4646
@element.page_version = @page_version
4747
@elements = @page.available_element_definitions
48-
render :new, status: :unprocessable_entity
48+
render :new, status: 422
4949
end
5050
end
5151

@@ -74,7 +74,7 @@ def update
7474
errorMessage: ingredient.errors.messages[:value].to_sentence
7575
}
7676
end
77-
}, status: :unprocessable_entity
77+
}, status: 422
7878
end
7979
end
8080

app/controllers/alchemy/admin/layoutpages_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def update
2626
@while_page_edit = request.referer.include?("edit")
2727
render "alchemy/admin/pages/update"
2828
else
29-
render :edit, status: :unprocessable_entity
29+
render :edit, status: 422
3030
end
3131
end
3232

app/controllers/alchemy/admin/legacy_page_urls_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def update
2222
@message = message_for_resource_action
2323
render :update
2424
else
25-
render :edit, status: :unprocessable_entity
25+
render :edit, status: 422
2626
end
2727
end
2828

app/controllers/alchemy/admin/nodes_controller.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,20 +34,20 @@ def create
3434
flash_notice_for_resource_action(:create)
3535
do_redirect_to(admin_nodes_path)
3636
else
37-
render :new, status: :unprocessable_entity
37+
render :new, status: 422
3838
end
3939
rescue => e
4040
flash[:error] = e.message
4141
new # Reinitialize instance variables like @node
42-
render :new, status: :unprocessable_entity
42+
render :new, status: 422
4343
end
4444
else
4545
@node = Node.new(resource_params)
4646
if @node.save
4747
flash_notice_for_resource_action(:create)
4848
do_redirect_to(admin_nodes_path)
4949
else
50-
render :new, status: :unprocessable_entity
50+
render :new, status: 422
5151
end
5252
end
5353
end

app/controllers/alchemy/admin/pages_controller.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ def update
139139
flash[:notice] = @notice
140140
end
141141
else
142-
render :configure, status: :unprocessable_entity
142+
render :configure, status: 422
143143
end
144144
end
145145

@@ -175,7 +175,7 @@ def fold
175175
if was_folded
176176
@page = PageTreePreloader.new(page: @page, user: current_alchemy_user).call
177177
else
178-
head :ok
178+
head 200
179179
end
180180
end
181181
end

app/controllers/alchemy/admin/pictures_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def update
8989
type: "error"
9090
}
9191
end
92-
render :update, status: (@message[:type] == "notice") ? :ok : :unprocessable_entity
92+
render :update, status: (@message[:type] == "notice") ? 200 : 422
9393
end
9494

9595
def update_multiple

app/controllers/alchemy/base_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def permission_denied(exception = nil)
5454
WARN
5555
end
5656
if request.format.json?
57-
render json: {message: Alchemy.t("You are not authorized")}, status: :unauthorized
57+
render json: {message: Alchemy.t("You are not authorized")}, status: 401
5858
elsif current_alchemy_user
5959
handle_redirect_for_user
6060
else

app/controllers/alchemy/pages_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ def page_locale_redirect_url(options = {})
157157

158158
# Redirects to given url with 301 status
159159
def redirect_permanently_to(url)
160-
redirect_to url, status: :moved_permanently
160+
redirect_to url, status: 301
161161
end
162162

163163
# Returns url parameters that are not internal show page params.

0 commit comments

Comments
 (0)