From de4acd4fa5b7a22b0971510934dd6418dc19f839 Mon Sep 17 00:00:00 2001 From: Julianna Tetreault <32834804+juliannatetreault@users.noreply.github.com> Date: Tue, 30 Aug 2022 09:16:58 -0600 Subject: [PATCH] =?UTF-8?q?Remove=20Community=20Emoji=20from=20Admin=20Con?= =?UTF-8?q?fig=20=F0=9F=8C=B1=20(#16902)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Removes all community_emoji-related code * Removes community_emoji-related specs from codebase * Updates communitySection.spec.js to test for member_label * chore: merge conflicts * feat: remove data update script * chore: add file back Co-authored-by: Ridhwana --- app/helpers/application_helper.rb | 4 -- app/lib/constants/settings/community.rb | 4 -- app/models/settings/community.rb | 1 - .../admin/settings/forms/_community.html.erb | 9 --- .../config/communitySection.spec.js | 67 ------------------- ...20220815102733_backfill_community_emoji.rb | 2 + .../backfill_community_emoji_spec.rb | 31 --------- spec/models/settings/community_spec.rb | 14 ---- spec/requests/admin/configs_spec.rb | 19 ------ 9 files changed, 2 insertions(+), 149 deletions(-) delete mode 100644 cypress/e2e/seededFlows/adminFlows/config/communitySection.spec.js delete mode 100644 spec/lib/data_update_scripts/backfill_community_emoji_spec.rb diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index caf345a2e..73782eef8 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -232,10 +232,6 @@ module ApplicationHelper @community_name ||= Settings::Community.community_name end - def community_emoji - @community_emoji ||= Settings::Community.community_emoji - end - def release_adjusted_cache_key(path) release_footprint = ForemInstance.deployed_at return path if release_footprint.blank? diff --git a/app/lib/constants/settings/community.rb b/app/lib/constants/settings/community.rb index df3551ec4..2903ceb34 100644 --- a/app/lib/constants/settings/community.rb +++ b/app/lib/constants/settings/community.rb @@ -7,10 +7,6 @@ module Constants description: I18n.t("lib.constants.settings.community.description.description"), placeholder: I18n.t("lib.constants.settings.community.description.placeholder") }, - community_emoji: { - description: I18n.t("lib.constants.settings.community.emoji.description"), - placeholder: "" - }, community_name: { description: I18n.t("lib.constants.settings.community.name.description"), placeholder: I18n.t("lib.constants.settings.community.name.placeholder") diff --git a/app/models/settings/community.rb b/app/models/settings/community.rb index 0b7f4aa3b..a18344ee6 100644 --- a/app/models/settings/community.rb +++ b/app/models/settings/community.rb @@ -6,7 +6,6 @@ module Settings type: :integer, default: ApplicationConfig["COMMUNITY_COPYRIGHT_START_YEAR"] || Time.zone.today.year setting :community_description, type: :string - setting :community_emoji, type: :string, default: "🌱", validates: { emoji_only: true } setting( :community_name, type: :string, diff --git a/app/views/admin/settings/forms/_community.html.erb b/app/views/admin/settings/forms/_community.html.erb index 690aca676..6116aadf3 100644 --- a/app/views/admin/settings/forms/_community.html.erb +++ b/app/views/admin/settings/forms/_community.html.erb @@ -14,15 +14,6 @@ placeholder: Constants::Settings::Community.details[:community_name][:placeholder] %> -
- <%= admin_config_label :community_emoji, model: Settings::Community %> - <%= admin_config_description Constants::Settings::Community.details[:community_emoji][:description] %> - <%= f.text_field :community_emoji, - class: "crayons-textfield", - value: Settings::Community.community_emoji, - placeholder: Constants::Settings::Community.details[:community_emoji][:placeholder] %> -
-
<%= admin_config_label :tagline, model: Settings::Community %> <%= admin_config_description Constants::Settings::Community.details[:tagline][:description] %> diff --git a/cypress/e2e/seededFlows/adminFlows/config/communitySection.spec.js b/cypress/e2e/seededFlows/adminFlows/config/communitySection.spec.js deleted file mode 100644 index fe88b1637..000000000 --- a/cypress/e2e/seededFlows/adminFlows/config/communitySection.spec.js +++ /dev/null @@ -1,67 +0,0 @@ -describe('Community Content Section', () => { - beforeEach(() => { - cy.testSetup(); - cy.fixture('users/adminUser.json').as('user'); - - cy.get('@user').then((user) => { - cy.loginUser(user); - }); - }); - - describe('community emoji setting', () => { - it('rejects invalid input (no emoji)', () => { - cy.get('@user').then(() => { - cy.visit('/admin/customization/config'); - cy.get('#new_settings_community').as('communitySectionForm'); - - cy.get('@communitySectionForm').findByText('Community Content').click(); - cy.get('@communitySectionForm') - .get('#settings_community_community_emoji') - .clear() - .type('X'); - - cy.get('@communitySectionForm').findByText('Update Settings').click(); - - cy.findByTestId('snackbar').within(() => { - cy.findByRole('alert').should( - 'have.text', - 'Validation failed: Community emoji contains non-emoji characters or invalid emoji', - ); - }); - - cy.url().should('contains', '/admin/customization/config'); - }); - }); - - it('accepts a valid emoji', () => { - cy.get('@user').then(() => { - cy.visit('/admin/customization/config'); - cy.get('#new_settings_community').as('communitySectionForm'); - - cy.get('@communitySectionForm').findByText('Community Content').click(); - cy.get('@communitySectionForm') - .get('#settings_community_community_emoji') - .clear() - .type('🌱'); - - cy.get('@communitySectionForm').findByText('Update Settings').click(); - - cy.url().should('contains', '/admin/customization/config'); - - cy.findByTestId('snackbar').within(() => { - cy.findByRole('alert').should( - 'have.text', - 'Successfully updated settings.', - ); - }); - - // Page reloaded so need to get a new reference to the form. - cy.get('#new_settings_community').as('communitySectionForm'); - cy.get('#settings_community_community_emoji').should( - 'have.value', - '🌱', - ); - }); - }); - }); -}); diff --git a/lib/data_update_scripts/20220815102733_backfill_community_emoji.rb b/lib/data_update_scripts/20220815102733_backfill_community_emoji.rb index 7d9dcdda1..31d132c55 100644 --- a/lib/data_update_scripts/20220815102733_backfill_community_emoji.rb +++ b/lib/data_update_scripts/20220815102733_backfill_community_emoji.rb @@ -1,5 +1,7 @@ module DataUpdateScripts class BackfillCommunityEmoji + # We can remove this file in the future once we've given self hosters sufficient + # time to update their Forems to run this script. def run return if Settings::Community.community_emoji.blank? return if Settings::Community.community_name.include?(Settings::Community.community_emoji) diff --git a/spec/lib/data_update_scripts/backfill_community_emoji_spec.rb b/spec/lib/data_update_scripts/backfill_community_emoji_spec.rb deleted file mode 100644 index 7894e5214..000000000 --- a/spec/lib/data_update_scripts/backfill_community_emoji_spec.rb +++ /dev/null @@ -1,31 +0,0 @@ -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 diff --git a/spec/models/settings/community_spec.rb b/spec/models/settings/community_spec.rb index 83e435445..24436ed10 100644 --- a/spec/models/settings/community_spec.rb +++ b/spec/models/settings/community_spec.rb @@ -16,18 +16,4 @@ RSpec.describe Settings::Community do end.not_to raise_error end end - - describe "validating emojis strings" do - it "allows emoji-only strings" do - expect do - described_class.community_emoji = "💯" - end.not_to raise_error - end - - it "rejects non emoji-only strings" do - expect do - described_class.community_emoji = "abc" - end.to raise_error(/contains non-emoji characters or invalid emoji/) - end - end end diff --git a/spec/requests/admin/configs_spec.rb b/spec/requests/admin/configs_spec.rb index c8ef3f81a..502f2b89a 100644 --- a/spec/requests/admin/configs_spec.rb +++ b/spec/requests/admin/configs_spec.rb @@ -178,25 +178,6 @@ RSpec.describe "/admin/customization/config", type: :request do expect(Settings::Community.community_description).to eq(description) end - it "updates the community_emoji if valid" do - allow(Settings::Community).to receive(:community_emoji).and_call_original - emoji = "🥐" - post admin_settings_communities_path, params: { - settings_community: { community_emoji: emoji } - } - expect(Settings::Community.community_emoji).to eq(emoji) - end - - it "does not update the community_emoji if invalid" do - Settings::Community.community_emoji = "🥐" - not_an_emoji = "i love croissants" - expect do - post admin_settings_communities_path, params: { - settings_community: { community_emoji: not_an_emoji } - } - end.not_to change(Settings::Community, :community_emoji) - end - it "updates the community_name" do name_magoo = "Hey hey #{rand(100)}" post admin_settings_communities_path, params: {