DEV: add spec where missing upload doesn't fail a theme's CSS precompilation (#19075)
In this PR, we're making sure when a theme upload which is used in the theme's CSS is missing it won't break the stylesheet precompilation process. See also: 6ebd2cecda
This commit is contained in:
parent
eef3532952
commit
01aa42c4b4
|
@ -872,6 +872,49 @@ RSpec.describe Stylesheet::Manager do
|
||||||
content = StylesheetCache.last.content
|
content = StylesheetCache.last.content
|
||||||
expect(content).to match(/# sourceMappingURL=[^\/]+\.css\.map\?__ws=test\.localhost/)
|
expect(content).to match(/# sourceMappingURL=[^\/]+\.css\.map\?__ws=test\.localhost/)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "generates precompiled CSS with a missing upload" do
|
||||||
|
image = file_from_fixtures("logo.png")
|
||||||
|
upload = UploadCreator.new(image, "logo.png").create_for(-1)
|
||||||
|
|
||||||
|
scheme = ColorScheme.create!(name: "scheme")
|
||||||
|
core_targets = [:desktop, :mobile, :desktop_rtl, :mobile_rtl, :admin, :wizard]
|
||||||
|
theme_targets = [:desktop_theme, :mobile_theme]
|
||||||
|
|
||||||
|
default_theme = Fabricate(:theme, color_scheme: scheme).tap do |t|
|
||||||
|
field = ThemeField.create!(
|
||||||
|
theme_id: t.id,
|
||||||
|
target_id: Theme.targets[:common],
|
||||||
|
name: "logo",
|
||||||
|
value: "",
|
||||||
|
upload_id: upload.id,
|
||||||
|
type_id: ThemeField.types[:theme_upload_var]
|
||||||
|
)
|
||||||
|
|
||||||
|
t.set_field(
|
||||||
|
target: :common,
|
||||||
|
name: :scss,
|
||||||
|
value: "body { background: url($logo); border: 3px solid green; }"
|
||||||
|
)
|
||||||
|
|
||||||
|
t.save!
|
||||||
|
end
|
||||||
|
|
||||||
|
default_theme.set_default!
|
||||||
|
upload.destroy!
|
||||||
|
StylesheetCache.destroy_all
|
||||||
|
|
||||||
|
Stylesheet::Manager.precompile_theme_css
|
||||||
|
|
||||||
|
manager = manager(default_theme.id)
|
||||||
|
theme_builder = Stylesheet::Manager::Builder.new(
|
||||||
|
target: :desktop_theme,
|
||||||
|
theme: default_theme,
|
||||||
|
manager: manager
|
||||||
|
)
|
||||||
|
css = File.read(theme_builder.stylesheet_fullpath)
|
||||||
|
expect(css).to include("border:3px solid green}")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe ".fs_asset_cachebuster" do
|
describe ".fs_asset_cachebuster" do
|
||||||
|
|
Loading…
Reference in New Issue