Skip to content

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

DEV: Fix another frozen string error.

Guo Xiang Tane2444e0d3158
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 152bebae7dd..892380ab198 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -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
diff --git a/spec/requests/application_controller_spec.rb b/spec/requests/application_controller_spec.rb
index 531a86cf71c..4a40d717937 100644
--- a/spec/requests/application_controller_spec.rb
+++ b/spec/requests/application_controller_spec.rb
@@ -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
diff --git a/spec/requests/posts_controller_spec.rb b/spec/requests/posts_controller_spec.rb
index dea1680497e..8044572b684 100644
--- a/spec/requests/posts_controller_spec.rb
+++ b/spec/requests/posts_controller_spec.rb
@@ -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)