FIX: title was repeating on about page

FIX: title was repeating on about page

From 654d7996aef6309e328285baf95ff5268e42a440 Mon Sep 17 00:00:00 2001
From: Arpit Jalan <arpit@techapj.com>
Date: Wed, 28 Nov 2018 08:06:14 +0530
Subject: [PATCH] FIX: title was repeating on about page


diff --git a/app/views/about/index.html.erb b/app/views/about/index.html.erb
index e27fb7e..34d034c 100644
--- a/app/views/about/index.html.erb
+++ b/app/views/about/index.html.erb
@@ -1,7 +1,5 @@
 <% if crawler_layout? %>
 
-<% content_for :title do %><%=t "about" %> - <%= SiteSetting.title %><% end %>
-
 <section itemscope itemtype="https://schema.org/AboutPage">
   <h1 itemprop="name">
     <%=t "js.about.title", {title: @about.title} %>
diff --git a/spec/requests/about_controller_spec.rb b/spec/requests/about_controller_spec.rb
index cf7ab39..541333c 100644
--- a/spec/requests/about_controller_spec.rb
+++ b/spec/requests/about_controller_spec.rb
@@ -9,6 +9,7 @@ describe AboutController do
       get "/about"
 
       expect(response.status).to eq(200)
+      expect(response.body).to include("<title>About - Discourse</title>")
     end
 
     it 'should redirect to login page for anonymous user when login_required is true' do
@@ -25,5 +26,13 @@ describe AboutController do
 
       expect(response.status).to eq(200)
     end
+
+    context "crawler view" do
+      it "should include correct title" do
+        get '/about', headers: { 'HTTP_USER_AGENT' => 'Googlebot' }
+        expect(response.status).to eq(200)
+        expect(response.body).to include("<title>About - Discourse</title>")
+      end
+    end
   end
 end
diff --git a/spec/requests/static_controller_spec.rb b/spec/requests/static_controller_spec.rb
index df12d0d..37a0f4c 100644
--- a/spec/requests/static_controller_spec.rb
+++ b/spec/requests/static_controller_spec.rb
@@ -101,6 +101,7 @@ describe StaticController do
 
         expect(response.status).to eq(200)
         expect(response.body).to include(I18n.t('js.faq'))
+        expect(response.body).to include("<title>FAQ - Discourse</title>")
       end
     end
 
@@ -186,6 +187,14 @@ describe StaticController do
         end
       end
     end
+
+    context "crawler view" do
+      it "should include correct title" do
+        get '/faq', headers: { 'HTTP_USER_AGENT' => 'Googlebot' }
+        expect(response.status).to eq(200)
+        expect(response.body).to include("<title>FAQ - Discourse</title>")
+      end
+    end
   end
 
   describe '#enter' do

GitHub

2 Likes