Remove Community Emoji from Admin Config 🌱 (#16902)
* 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 <ridhwana.khan16@gmail.com>
This commit is contained in:
parent
2ff67bda24
commit
de4acd4fa5
9 changed files with 2 additions and 149 deletions
|
|
@ -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?
|
||||
|
|
|
|||
|
|
@ -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")
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -14,15 +14,6 @@
|
|||
placeholder: Constants::Settings::Community.details[:community_name][:placeholder] %>
|
||||
</div>
|
||||
|
||||
<div class="crayons-field">
|
||||
<%= 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] %>
|
||||
</div>
|
||||
|
||||
<div class="crayons-field">
|
||||
<%= admin_config_label :tagline, model: Settings::Community %>
|
||||
<%= admin_config_description Constants::Settings::Community.details[:tagline][:description] %>
|
||||
|
|
|
|||
|
|
@ -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',
|
||||
'🌱',
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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: {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue