DEV: deprecate blank files for static modal pages

This commit is contained in:
Arpit Jalan 2019-03-04 15:04:48 +05:30
parent 2e881adb6e
commit ad5f5b931d
4 changed files with 18 additions and 12 deletions

View File

@ -9,6 +9,7 @@ class StaticController < ApplicationController
skip_before_action :handle_theme, only: [:brotli_asset, :cdn_asset, :enter, :favicon, :service_worker_asset]
PAGES_WITH_EMAIL_PARAM = ['login', 'password_reset', 'signup']
MODAL_PAGES = ['password_reset', 'signup']
def show
return redirect_to(path '/') if current_user && (params[:id] == 'login' || params[:id] == 'signup')
@ -69,6 +70,11 @@ class StaticController < ApplicationController
return
end
if MODAL_PAGES.include?(@page)
render html: nil, layout: true
return
end
raise Discourse::NotFound
end

View File

@ -1 +0,0 @@
<!-- this file is required to show the password reset modal: /password-reset -->

View File

@ -1 +0,0 @@
<!-- this file is required to show the signup modal: /signup -->

View File

@ -103,16 +103,6 @@ describe StaticController do
expect(response.body).to include(I18n.t('js.faq'))
expect(response.body).to include("<title>FAQ - Discourse</title>")
end
it "should return the right response for /signup" do
get "/signup"
expect(response.status).to eq(200)
end
it "should return the right response for /password-reset" do
get "/password-reset"
expect(response.status).to eq(200)
end
end
[
@ -149,6 +139,18 @@ describe StaticController do
get "/static/does-not-exist"
expect(response.status).to eq(404)
end
context "modal pages" do
it "should return the right response for /signup" do
get "/signup"
expect(response.status).to eq(200)
end
it "should return the right response for /password-reset" do
get "/password-reset"
expect(response.status).to eq(200)
end
end
end
it 'should redirect to / when logged in and path is /login' do