Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test branch name change impact for 5524 format error handling #7490

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion app/controllers/errors_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
class ErrorsController < ApplicationController
before_action :update_locale, :set_error_name
def show
render :show, status: status_for(@error_name)
respond_to do |format|
format.html { render :show, status: status_for(@error_name) }
format.all { render plain: "Not found", status: :not_found }
end
end

private
Expand Down
26 changes: 25 additions & 1 deletion spec/requests/errors_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
let(:get_invalid_path) { get("/unknown/path") }

context "with default locale" do
it "responds with http status" do
it "responds with expected http status" do
get_invalid_path
expect(response).to have_http_status(:not_found)
end
Expand All @@ -29,6 +29,30 @@
end
end

context "when page not found due to non-html format" do
let(:get_invalid_path) { get("/unknown/path.xml") }

context "with default locale" do
it "responds with expected http status" do
get_invalid_path
expect(response).to have_http_status(:not_found)
end

it "renders not found plain text" do
get_invalid_path
expect(response.body).to eq("Not found")
end
end

context "with Welsh locale", :use_welsh_locale do
it "displays the correct content" do
get("/unknown/path.xml", params: { locale: :cy })

expect(response.body).to eq("Not found")
end
end
end

context "when page not found due to object not found" do
let(:get_invalid_id) { get feedback_path(SecureRandom.uuid) }

Expand Down