Remove Remaining logo_svg Code (#16291)
* Removes logo_svg-related code * Removes logo_svg-related specs * Removes the logo_uploader and logo_uploader DUS spec * Removes the logo_uploader_spec.rb * Adds a DUS to remove the logo_svg var from the DB * Reverts the removal of the logo_svg_uploader.rb
This commit is contained in:
parent
5fc1f48e51
commit
45b7806120
9 changed files with 8 additions and 125 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ module Constants
|
|||
module Settings
|
||||
module General
|
||||
IMAGE_PLACEHOLDER = "https://url/image.png".freeze
|
||||
SVG_PLACEHOLDER = "<svg ...></svg>".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)",
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,7 @@
|
|||
module DataUpdateScripts
|
||||
class RemoveLogoSvgFromDatabase
|
||||
def run
|
||||
Settings::General.destroy_by(var: :logo_svg)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -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 = '<svg xmlns="http://www.w3.org/2000/svg"
|
||||
width="120" height="120" viewPort="0 0 120 120" version="1.1">
|
||||
<rect width="150" height="150" fill="rgb(0, 255, 0)" stroke-width="1" stroke="rgb(0, 0, 0)" />
|
||||
<line x1="20" y1="100" x2="100" y2="20" stroke="black" stroke-width="2"/>
|
||||
</svg>'
|
||||
|
||||
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 = '<svg width="50" height="40" viewBox="0 0 50 40" fill="none" xmlns="http://www.w3.org/2000/svg"><rect width="50" height="40" rx="3" style="fill: currentColor;"></rect><path d="M19.099 23.508c0 1.31-.423 2.388-1.27 3.234-.838.839-1.942 1.258-3.312 1.258h-4.403V12.277h4.492c1.31 0 2.385.423 3.224 1.27.846.838 1.269 1.912 1.269 3.223v6.738zm-2.808 0V16.77c0-.562-.187-.981-.562-1.258-.374-.285-.748-.427-1.122-.427h-1.685v10.107h1.684c.375 0 .75-.138 1.123-.415.375-.285.562-.708.562-1.27zM28.185 28h-5.896c-.562 0-1.03-.187-1.404-.561-.375-.375-.562-.843-.562-1.404V14.243c0-.562.187-1.03.562-1.404.374-.375.842-.562 1.404-.562h5.896v2.808H23.13v3.65h3.088v2.808h-3.088v3.65h5.054V28zm7.12 0c-.936 0-1.684-.655-2.246-1.965l-3.65-13.758h3.089l2.807 10.804 2.808-10.804H41.2l-3.65 13.758C36.99 27.345 36.241 28 35.305 28z" style="fill: var(--base-inverted);"></path></svg>'
|
||||
# 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
|
||||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
Loading…
Add table
Reference in a new issue