FIX: Remove category id from category class name (#10712)

The generated class name included ID (parent_slug-child_slug-child_id),
but the client side did not expect it (parent_slug-child_slug).
This commit is contained in:
Bianca Nenciu 2020-09-23 19:22:07 +03:00 committed by GitHub
parent 9f73e8779d
commit 214b4c3910
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 5 deletions

View File

@ -257,7 +257,8 @@ module Stylesheet
end end
def category_css(category) def category_css(category)
"body.category-#{category.slug}, body.category-#{category.full_slug} { background-image: url(#{upload_cdn_path(category.uploaded_background.url)}) }\n" full_slug = category.full_slug.split("-")[0..-2].join("-")
"body.category-#{category.slug}, body.category-#{full_slug} { background-image: url(#{upload_cdn_path(category.uploaded_background.url)}) }\n"
end end
def font_css(font) def font_css(font)

View File

@ -13,12 +13,13 @@ describe Stylesheet::Importer do
expect(compile_css("category_backgrounds")).to_not include("background-image") expect(compile_css("category_backgrounds")).to_not include("background-image")
background = Fabricate(:upload) background = Fabricate(:upload)
category = Fabricate(:category, uploaded_background: background) parent_category = Fabricate(:category)
category = Fabricate(:category, parent_category_id: parent_category.id, uploaded_background: background)
expect(compile_css("category_backgrounds")).to include("body.category-#{category.slug},body.category-#{category.full_slug}{background-image:url(#{background.url})}") expect(compile_css("category_backgrounds")).to include("body.category-#{category.slug},body.category-#{parent_category.slug}-#{category.slug}{background-image:url(#{background.url})}")
GlobalSetting.stubs(:cdn_url).returns("//awesome.cdn") GlobalSetting.stubs(:cdn_url).returns("//awesome.cdn")
expect(compile_css("category_backgrounds")).to include("body.category-#{category.slug},body.category-#{category.full_slug}{background-image:url(//awesome.cdn#{background.url})}") expect(compile_css("category_backgrounds")).to include("body.category-#{category.slug},body.category-#{parent_category.slug}-#{category.slug}{background-image:url(//awesome.cdn#{background.url})}")
end end
it "applies S3 CDN to background category images" do it "applies S3 CDN to background category images" do
@ -32,7 +33,7 @@ describe Stylesheet::Importer do
background = Fabricate(:upload_s3) background = Fabricate(:upload_s3)
category = Fabricate(:category, uploaded_background: background) category = Fabricate(:category, uploaded_background: background)
expect(compile_css("category_backgrounds")).to include("body.category-#{category.full_slug}{background-image:url(https://s3.cdn/original") expect(compile_css("category_backgrounds")).to include("body.category-#{category.slug}{background-image:url(https://s3.cdn/original")
end end
it "includes font variable" do it "includes font variable" do