Backfill community_emoji data with a DUS 🌱 (#16896)
* Adds a DUS to backfill community_emoji for Forems that have one * Adds a DUS spec to test backfilling community names * update the script adn the tests to allow us to change the community name * feat: add a stub for the community name * feat: generate a later timestamp so that it doesnt cause confusion * chcek if the emoji already appears in the community name * feat: remove community emoji from displaying on the UI * refactor:remove the else if completely Co-authored-by: Ridhwana <ridhwana.khan16@gmail.com>
This commit is contained in:
parent
b6efce21fe
commit
806a5a774e
6 changed files with 47 additions and 10 deletions
|
|
@ -93,8 +93,6 @@ module ApplicationHelper
|
|||
def title(page_title)
|
||||
derived_title = if page_title.include?(community_name)
|
||||
page_title
|
||||
elsif user_signed_in?
|
||||
"#{page_title} - #{community_name} #{community_emoji}"
|
||||
else
|
||||
"#{page_title} - #{community_name}"
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<%= content_for :page_meta do %>
|
||||
<% title_with_timeframe(
|
||||
page_title: "#{community_name} #{community_emoji}",
|
||||
page_title: community_name,
|
||||
timeframe: params[:timeframe],
|
||||
content_for: true,
|
||||
) %>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,11 @@
|
|||
module DataUpdateScripts
|
||||
class BackfillCommunityEmoji
|
||||
def run
|
||||
return if Settings::Community.community_emoji.blank?
|
||||
return if Settings::Community.community_name.include?(Settings::Community.community_emoji)
|
||||
|
||||
new_community_name = "#{Settings::Community.community_name} #{Settings::Community.community_emoji}"
|
||||
Settings::Community.community_name = new_community_name
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
require "rails_helper"
|
||||
require Rails.root.join(
|
||||
"lib/data_update_scripts/20220815102733_backfill_community_emoji.rb",
|
||||
)
|
||||
|
||||
describe DataUpdateScripts::BackfillCommunityEmoji do
|
||||
it "does not update the community_name if the community does not have a community_emoji" do
|
||||
allow(Settings::Community).to receive(:community_name).and_return("Emoji less Community")
|
||||
allow(Settings::Community).to receive(:community_emoji).and_return(nil)
|
||||
|
||||
expect do
|
||||
described_class.new.run
|
||||
end.not_to change(Settings::Community, :community_name)
|
||||
end
|
||||
|
||||
it "updates the community_name if the community has a community_emoji" do
|
||||
Settings::Community.community_name = "Emoji Community"
|
||||
Settings::Community.community_emoji = "🥐"
|
||||
|
||||
described_class.new.run
|
||||
expect(Settings::Community.community_name).to eq("Emoji Community 🥐")
|
||||
end
|
||||
|
||||
it "does not update the community_name if the community_emoji is already at the end" do
|
||||
Settings::Community.community_name = "Emoji Community 🥐"
|
||||
Settings::Community.community_emoji = "🥐"
|
||||
|
||||
described_class.new.run
|
||||
expect(Settings::Community.community_name).to eq("Emoji Community 🥐")
|
||||
end
|
||||
end
|
||||
|
|
@ -5,6 +5,7 @@ RSpec.describe "OpenSearch", type: :request do
|
|||
|
||||
describe "GET /open-search.xml" do
|
||||
it "has proper information" do
|
||||
allow(Settings::Community).to receive(:community_name).and_return("Community")
|
||||
get "/open-search.xml"
|
||||
expect(response.body).to include("<ShortName>#{Settings::Community.community_name} Search</ShortName>")
|
||||
end
|
||||
|
|
|
|||
|
|
@ -46,12 +46,10 @@ RSpec.describe "StoriesShow", type: :request do
|
|||
|
||||
## Title tag
|
||||
it "renders signed-in title tag for signed-in user" do
|
||||
allow(Settings::Community).to receive(:community_emoji).and_return("🌱")
|
||||
|
||||
sign_in user
|
||||
get article.path
|
||||
|
||||
title = "<title>#{CGI.escapeHTML(article.title)} - #{community_name} #{community_emoji}</title>"
|
||||
title = "<title>#{CGI.escapeHTML(article.title)} - #{community_name}</title>"
|
||||
expect(response.body).to include(title)
|
||||
end
|
||||
|
||||
|
|
@ -71,13 +69,11 @@ RSpec.describe "StoriesShow", type: :request do
|
|||
end
|
||||
|
||||
it "does not render title tag with search_optimized_title_preamble if set and not signed in" do
|
||||
allow(Settings::Community).to receive(:community_emoji).and_return("🌱")
|
||||
|
||||
sign_in user
|
||||
article.update_column(:search_optimized_title_preamble, "Hey this is a test")
|
||||
get article.path
|
||||
|
||||
title = "<title>#{CGI.escapeHTML(article.title)} - #{community_name} #{community_emoji}</title>"
|
||||
title = "<title>#{CGI.escapeHTML(article.title)} - #{community_name}</title>"
|
||||
expect(response.body).to include(title)
|
||||
end
|
||||
|
||||
|
|
@ -198,7 +194,7 @@ RSpec.describe "StoriesShow", type: :request do
|
|||
# rubocop:enable RSpec/MessageChain
|
||||
get article.path
|
||||
|
||||
expect(response.status).to eq(400)
|
||||
expect(response).to have_http_status(:bad_request)
|
||||
end
|
||||
|
||||
it "has noindex if article has low score" do
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue