diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 0debdd95f..e711ed42e 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -182,15 +182,6 @@ module ApplicationHelper "/t/#{params[:tag]}" end - def logo_svg - if Settings::General.logo_svg.present? - Settings::General.logo_svg.html_safe # rubocop:disable Rails/OutputSafety - else - inline_svg_tag("devplain.svg", class: "logo", size: "20% * 20%", aria: true, - title: I18n.t("helpers.application_helper.app_logo")) - end - end - def community_name @community_name ||= Settings::Community.community_name end diff --git a/app/lib/constants/settings/general.rb b/app/lib/constants/settings/general.rb index 8cebf18bb..d80060c40 100644 --- a/app/lib/constants/settings/general.rb +++ b/app/lib/constants/settings/general.rb @@ -2,7 +2,6 @@ module Constants module Settings module General IMAGE_PLACEHOLDER = "https://url/image.png".freeze - SVG_PLACEHOLDER = "".freeze DETAILS = { contact_email: { @@ -45,11 +44,6 @@ module Constants "Recommended minimum of 512x512px", placeholder: IMAGE_PLACEHOLDER }, - logo_svg: { - description: "This is the logo currently used on the upper left-hand corner of your Forem. " \ - "However, after the release it will be deprecated in favor of the Logo above.", - placeholder: SVG_PLACEHOLDER - }, main_social_image: { description: "Used as the main image in social networks and OpenGraph. Recommended aspect ratio " \ "of 16:9 (600x337px,1200x675px)", diff --git a/app/models/settings/general.rb b/app/models/settings/general.rb index 9932220e2..252c46fcb 100644 --- a/app/models/settings/general.rb +++ b/app/models/settings/general.rb @@ -36,8 +36,6 @@ module Settings default: proc { URL.local_image("icon.png") }, validates: { url: true } - setting :logo_svg, type: :string - setting :original_logo, type: :string setting :resized_logo, type: :string diff --git a/lib/data_update_scripts/20220203143904_remove_logo_svg_from_database.rb b/lib/data_update_scripts/20220203143904_remove_logo_svg_from_database.rb new file mode 100644 index 000000000..1df1b9edc --- /dev/null +++ b/lib/data_update_scripts/20220203143904_remove_logo_svg_from_database.rb @@ -0,0 +1,7 @@ +module DataUpdateScripts + class RemoveLogoSvgFromDatabase + def run + Settings::General.destroy_by(var: :logo_svg) + end + end +end diff --git a/spec/lib/data_update_scripts/migrate_logo_svg_data_spec.rb b/spec/lib/data_update_scripts/migrate_logo_svg_data_spec.rb deleted file mode 100644 index b6ae63068..000000000 --- a/spec/lib/data_update_scripts/migrate_logo_svg_data_spec.rb +++ /dev/null @@ -1,42 +0,0 @@ -require "rails_helper" -require Rails.root.join( - "lib/data_update_scripts/20220105112823_migrate_logo_svg_data.rb", -) - -describe DataUpdateScripts::MigrateLogoSvgData do - # This simply tests the output of the script, however, - # the manner in which the uploader behaves is tested by logo_svg_uploader_spec.rb - - context "when the svg is able to be processed" do - processable_svg_string = ' - - - ' - - it "returns the logo url with a png extension", :aggregate_failures do - allow(Settings::General).to receive(:logo_svg).and_return(processable_svg_string) - described_class.new.run - - expect(::Settings::General.original_logo).to include(".png") - expect(::Settings::General.resized_logo).to include(".png") - end - end - - context "when the svg is unable to be processed" do - # rubocop:disable Layout/LineLength - unprocessable_svg_string = '' - # rubocop:enable Layout/LineLength - - it "logs an error" do - allow(Settings::General).to receive(:logo_svg).and_return(unprocessable_svg_string) - allow(Honeybadger).to receive(:notify) - allow(LogoSvgUploader).to receive(:new).and_raise(StandardError) - - described_class.new.run - expect(Honeybadger).to have_received(:notify).once - expect(::Settings::General.original_logo).to be(nil) - expect(::Settings::General.resized_logo).to be(nil) - end - end -end diff --git a/spec/requests/admin/configs_spec.rb b/spec/requests/admin/configs_spec.rb index 7c44af694..e2e5a5742 100644 --- a/spec/requests/admin/configs_spec.rb +++ b/spec/requests/admin/configs_spec.rb @@ -330,14 +330,6 @@ RSpec.describe "/admin/customization/config", type: :request do } end.not_to change(Settings::General, :logo_png) end - - it "updates logo_svg" do - expected_image_url = "https://dummyimage.com/300x300.png" - post admin_settings_general_settings_path, params: { - settings_general: { logo_svg: expected_image_url } - } - expect(Settings::General.logo_svg).to eq(expected_image_url) - end end describe "Mascot" do diff --git a/spec/system/articles/user_edits_an_article_spec.rb b/spec/system/articles/user_edits_an_article_spec.rb index 53072fc96..aafd9ac44 100644 --- a/spec/system/articles/user_edits_an_article_spec.rb +++ b/spec/system/articles/user_edits_an_article_spec.rb @@ -12,7 +12,6 @@ RSpec.describe "Editing with an editor", type: :system, js: true do allow(Settings::General).to receive(:mascot_image_url).and_return("https://dummyimage.com/800x600.jpg") allow(Settings::General).to receive(:suggested_tags).and_return("coding, beginners") allow(Settings::General).to receive(:suggested_users).and_return("romagueramica") - allow(Settings::General).to receive(:logo_svg).and_return(svg_image) sign_in user end diff --git a/spec/system/user_uses_the_editor_spec.rb b/spec/system/user_uses_the_editor_spec.rb index aa6362959..86ed89589 100644 --- a/spec/system/user_uses_the_editor_spec.rb +++ b/spec/system/user_uses_the_editor_spec.rb @@ -23,7 +23,7 @@ RSpec.describe "Using the editor", type: :system do end describe "Viewing the editor", js: true do - it "renders the logo_svg or Community name as expected" do + it "renders the logo or Community name as expected" do visit "/new" expect(page).to have_css(".site-logo") within(".truncate-at-2") do diff --git a/spec/uploaders/logo_svg_uploader_spec.rb b/spec/uploaders/logo_svg_uploader_spec.rb deleted file mode 100644 index 83cb8fcc0..000000000 --- a/spec/uploaders/logo_svg_uploader_spec.rb +++ /dev/null @@ -1,56 +0,0 @@ -require "rails_helper" -require "carrierwave/test/matchers" -require "exifr/jpeg" - -describe LogoSvgUploader, type: :uploader do - include CarrierWave::Test::Matchers - - let(:image_svg) { fixture_file_upload("300x100.svg", "image/svg+xml") } - let(:image_webp) { fixture_file_upload("800x600.webp", "image/webp") } - - # we need a new uploader before each test, and since the uploader is not a model - # we can recreate it quickly in memory with `let!` - let!(:uploader) { described_class.new } - - before do - described_class.include CarrierWave::MiniMagick # needed for processing - described_class.enable_processing = true - end - - after do - described_class.enable_processing = false - uploader.remove! - end - - it "stores files in the correct directory" do - expect(uploader.store_dir).to eq("uploads/logos/") - end - - describe "error handling" do - it "raises a CarrierWave error which can be parsed if MiniMagick timeout occurs" do - allow(MiniMagick::Image).to receive(:new).and_raise(Timeout::Error) - - expect { uploader.store!(image_svg) }.to raise_error(CarrierWave::IntegrityError, /Image processing timed out/) - end - end - - describe "processed images" do - it "creates versions of the image with different filenames", :aggregate_failures do - uploader.store!(image_svg) - expect(uploader.filename).to match(/original_logo/) - expect(uploader.resized_logo.file.filename).to match(/resized_logo/) - end - - it "stores the processed logo's with a png file extension" do - uploader.store!(image_svg) - expect(uploader.filename).to match(/\.png\z/) - expect(uploader.resized_logo.file.filename).to match(/\.png\z/) - end - - it "stores the processed logo as a png content type" do - uploader.store!(image_svg) - expect(uploader.content_type).to match(/png/) - expect(uploader.resized_logo.file.content_type).to match(/png/) - end - end -end