diff --git a/app/views/pages/terms.html.erb b/app/views/pages/terms.html.erb
index 1663c2302..de54a78cb 100644
--- a/app/views/pages/terms.html.erb
+++ b/app/views/pages/terms.html.erb
@@ -3,7 +3,7 @@
<%= content_for :page_meta do %>
" />
-
+ <%= meta_keywords_default %>
" />
diff --git a/app/views/podcast_episodes/_meta.html.erb b/app/views/podcast_episodes/_meta.html.erb
index 865f0b10f..5886c45f8 100644
--- a/app/views/podcast_episodes/_meta.html.erb
+++ b/app/views/podcast_episodes/_meta.html.erb
@@ -4,7 +4,7 @@
<%= content_for :page_meta do %>
-
+ <%= meta_keywords_default %>
@@ -26,7 +26,7 @@
<%= content_for :page_meta do %>
-
+ <%= meta_keywords_default %>
diff --git a/app/views/podcast_episodes/show.html.erb b/app/views/podcast_episodes/show.html.erb
index 8aa7062d5..0308d66f0 100644
--- a/app/views/podcast_episodes/show.html.erb
+++ b/app/views/podcast_episodes/show.html.erb
@@ -3,7 +3,7 @@
<%= content_for :page_meta do %>
" />
-
+ <%= meta_keywords_default %>
" />
diff --git a/app/views/reading_list_items/index.html.erb b/app/views/reading_list_items/index.html.erb
index d87d9d113..f2ea6e52e 100644
--- a/app/views/reading_list_items/index.html.erb
+++ b/app/views/reading_list_items/index.html.erb
@@ -3,7 +3,7 @@
<%= content_for :page_meta do %>
" />
-
+ <%= meta_keywords_default %>
" />
diff --git a/app/views/tags/index.html.erb b/app/views/tags/index.html.erb
index c08e3f84f..afc3169f7 100644
--- a/app/views/tags/index.html.erb
+++ b/app/views/tags/index.html.erb
@@ -3,7 +3,7 @@
<%= content_for :page_meta do %>
" />
-
+ <%= meta_keywords_default %>
" />
diff --git a/app/views/users/_meta.html.erb b/app/views/users/_meta.html.erb
index bf34d06dc..8240df889 100644
--- a/app/views/users/_meta.html.erb
+++ b/app/views/users/_meta.html.erb
@@ -1,6 +1,6 @@
-
+<%= meta_keywords_default %>
diff --git a/app/views/videos/index.html.erb b/app/views/videos/index.html.erb
index 9a59cb78b..e44429fa5 100644
--- a/app/views/videos/index.html.erb
+++ b/app/views/videos/index.html.erb
@@ -3,7 +3,7 @@
<%= content_for :page_meta do %>
-
+ <%= meta_keywords_default %>
diff --git a/spec/requests/articles/articles_show_spec.rb b/spec/requests/articles/articles_show_spec.rb
index 17846350b..b9bc82507 100644
--- a/spec/requests/articles/articles_show_spec.rb
+++ b/spec/requests/articles/articles_show_spec.rb
@@ -78,7 +78,7 @@ RSpec.describe "ArticlesShow", type: :request do
end
# rubocop:enable RSpec/ExampleLength
- context "when keywords are set up" do
+ context "when keywords are set" do
it "shows keywords" do
SiteConfig.meta_keywords = { article: "hello, world" }
article.update_column(:cached_tag_list, "super sheep")
@@ -87,6 +87,17 @@ RSpec.describe "ArticlesShow", type: :request do
end
end
+ context "when keywords are not" do
+ it "does not show keywords" do
+ SiteConfig.meta_keywords = { article: "" }
+ article.update_column(:cached_tag_list, "super sheep")
+ get article.path
+ expect(response.body).not_to include(
+ '',
+ )
+ end
+ end
+
context "when user signed in" do
before do
sign_in user
diff --git a/spec/requests/stories_index_spec.rb b/spec/requests/stories_index_spec.rb
index 658f91ec2..c3606e855 100644
--- a/spec/requests/stories_index_spec.rb
+++ b/spec/requests/stories_index_spec.rb
@@ -119,12 +119,20 @@ RSpec.describe "StoriesIndex", type: :request do
expect(response.headers["X-Accel-Expires"]).to eq("600")
end
- it "shows default meta keywords" do
+ it "shows default meta keywords if set" do
SiteConfig.meta_keywords = { default: "cool developers, civil engineers" }
get "/"
expect(response.body).to include("")
end
+ it "does not show default meta keywords if not set" do
+ SiteConfig.meta_keywords = { default: "" }
+ get "/"
+ expect(response.body).not_to include(
+ "",
+ )
+ end
+
it "shows only one cover if basic feed style" do
create_list(:article, 3, featured: true, score: 20, main_image: "https://example.com/image.jpg")
@@ -348,12 +356,20 @@ RSpec.describe "StoriesIndex", type: :request do
expect(response.body).to include(sponsorship.blurb_html)
end
- it "shows meta keywords" do
+ it "shows meta keywords if set" do
SiteConfig.meta_keywords = { tag: "software engineering, ruby" }
get "/t/#{tag.name}"
expect(response.body).to include("")
end
+ it "does not show meta keywords if not set" do
+ SiteConfig.meta_keywords = { tag: "" }
+ get "/t/#{tag.name}"
+ expect(response.body).not_to include(
+ "",
+ )
+ end
+
context "with user signed in" do
before do
sign_in user
diff --git a/spec/system/admin/admin_manages_configuration_spec.rb b/spec/system/admin/admin_manages_configuration_spec.rb
index ab4f96cc3..7e96e3703 100644
--- a/spec/system/admin/admin_manages_configuration_spec.rb
+++ b/spec/system/admin/admin_manages_configuration_spec.rb
@@ -8,9 +8,7 @@ RSpec.describe "Admin manages configuration", type: :system do
visit admin_config_path
end
- # Note: The :meta_keywords are handled slightly differently in the view, so we
- # can't check them the same way as the rest.
- (VerifySetupCompleted::MANDATORY_CONFIGS - [:meta_keywords]).each do |option|
+ VerifySetupCompleted::MANDATORY_CONFIGS.each do |option|
it "marks #{option} as required" do
selector = "label[for='site_config_#{option}']"
expect(first(selector).text).to include("Required")