Skip to content

A platform for community discussion. Free, open, simple.

DEV: Add missing test case to `ApplicationController` (#35001)

Alan Guo Xiang Tan128e2f98ceee
diff --git a/spec/requests/application_controller_spec.rb b/spec/requests/application_controller_spec.rb
index 6d9fe68d5f5..102164c8aac 100644
--- a/spec/requests/application_controller_spec.rb
+++ b/spec/requests/application_controller_spec.rb
@@ -1,6 +1,24 @@
# frozen_string_literal: true
RSpec.describe ApplicationController do
+ fab!(:user)
+
+ context "when visiting an invalid URL" do
+ it "displays the not found page with the user's active theme" do
+ theme = Fabricate(:theme, user_selectable: true)
+ Fabricate(:theme_field, theme:, name: "header", value: "<a>html</a>")
+ user.user_option.update!(theme_ids: [theme.id])
+
+ sign_in(user)
+
+ get "/invalid-url"
+
+ expect(response.status).to eq(404)
+ expect(response.body).to include("<a>html</a>")
+ expect(response.body).to include(I18n.t("page_not_found.title"))
+ end
+ end
+
describe "#redirect_to_login_if_required" do
let(:admin) { Fabricate(:admin) }