mirror of
https://github.com/discourse/discourse.git
synced 2025-05-24 03:36:18 +08:00
FIX: not found page shouldn't include the Google search form for sites with login_required enabled
This commit is contained in:
@ -681,6 +681,7 @@ class ApplicationController < ActionController::Base
|
|||||||
@slug = params[:slug].class == String ? params[:slug] : ''
|
@slug = params[:slug].class == String ? params[:slug] : ''
|
||||||
@slug = (params[:id].class == String ? params[:id] : '') if @slug.blank?
|
@slug = (params[:id].class == String ? params[:id] : '') if @slug.blank?
|
||||||
@slug.tr!('-', ' ')
|
@slug.tr!('-', ' ')
|
||||||
|
@hide_google = true if SiteSetting.login_required
|
||||||
render_to_string status: status, layout: layout, formats: [:html], template: '/exceptions/not_found'
|
render_to_string status: status, layout: layout, formats: [:html], template: '/exceptions/not_found'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -14,4 +14,22 @@ RSpec.describe ApplicationController do
|
|||||||
expect(response).to redirect_to('/login?authComplete=true')
|
expect(response).to redirect_to('/login?authComplete=true')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe 'build_not_found_page' do
|
||||||
|
describe 'topic not found' do
|
||||||
|
it 'should return 404 and show Google search' do
|
||||||
|
get "/t/nope-nope/99999999"
|
||||||
|
expect(response.status).to eq(404)
|
||||||
|
expect(response.body).to include(I18n.t('page_not_found.search_google'))
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should not include Google search if login_required is enabled' do
|
||||||
|
SiteSetting.login_required = true
|
||||||
|
sign_in(Fabricate(:user))
|
||||||
|
get "/t/nope-nope/99999999"
|
||||||
|
expect(response.status).to eq(404)
|
||||||
|
expect(response.body).to_not include('google.com/search')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
Reference in New Issue
Block a user