DEV: Fix another frozen string error.

This commit is contained in:
Guo Xiang Tan 2019-05-17 10:07:18 +08:00
parent 96fbc14f80
commit e2444e0d31
3 changed files with 22 additions and 4 deletions

View File

@ -775,8 +775,7 @@ class ApplicationController < ActionController::Base
end
@container_class = "wrap not-found-container"
@slug = params[:slug].presence || params[:id].presence || ""
@slug.tr!('-', ' ')
@slug = (params[:slug].presence || params[:id].presence || "").tr('-', '')
@hide_search = true if SiteSetting.login_required
render_to_string status: status, layout: layout, formats: [:html], template: '/exceptions/not_found'
end

View File

@ -189,10 +189,15 @@ RSpec.describe ApplicationController do
expect(response).to redirect_to("/forum/t/#{new_topic.slug}/#{new_topic.id}/#{new_topic.posts.last.post_number}")
end
it 'should return 404 and show Google search' do
it 'should return 404 and show Google search for an invalid topic route' do
get "/t/nope-nope/99999999"
expect(response.status).to eq(404)
expect(response.body).to include(I18n.t('page_not_found.search_button'))
response_body = response.body
expect(response_body).to include(I18n.t('page_not_found.search_button'))
expect(response_body).to have_tag("input", with: { value: 'nopenope' })
end
it 'should not include Google search if login_required is enabled' do

View File

@ -1648,6 +1648,20 @@ describe PostsController do
describe '#latest' do
context 'private posts' do
describe 'when not logged in' do
it 'should return the right response' do
Fabricate(:post)
get "/private-posts.rss"
expect(response.status).to eq(404)
expect(response.body).to have_tag(
"input", with: { value: "private_posts" }
)
end
end
it 'returns private posts rss feed' do
sign_in(admin)