FIX: Show background images for both slug formats
It seems there was a discrepancy in that background images were attached to the full slug category class: `category-:slug-:id` and our body class only had `category-:slug`. This fix adds support for both formats.
This commit is contained in:
parent
db9162610a
commit
8e3f667d7c
|
@ -192,7 +192,7 @@ module Stylesheet
|
|||
end
|
||||
|
||||
def category_css(category)
|
||||
"body.category-#{category.full_slug} { background-image: url(#{upload_cdn_path(category.uploaded_background.url)}) }\n"
|
||||
"body.category-#{category.slug}, body.category-#{category.full_slug} { background-image: url(#{upload_cdn_path(category.uploaded_background.url)}) }\n"
|
||||
end
|
||||
|
||||
def to_scss_variable(name, value)
|
||||
|
|
|
@ -15,10 +15,10 @@ describe Stylesheet::Importer do
|
|||
background = Fabricate(:upload)
|
||||
category = Fabricate(:category, uploaded_background: background)
|
||||
|
||||
expect(compile_css("category_backgrounds")).to include("body.category-#{category.full_slug}{background-image:url(#{background.url})}")
|
||||
expect(compile_css("category_backgrounds")).to include("body.category-#{category.slug},body.category-#{category.full_slug}{background-image:url(#{background.url})}")
|
||||
|
||||
GlobalSetting.stubs(:cdn_url).returns("//awesome.cdn")
|
||||
expect(compile_css("category_backgrounds")).to include("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-#{category.full_slug}{background-image:url(//awesome.cdn#{background.url})}")
|
||||
end
|
||||
|
||||
it "applies S3 CDN to background category images" do
|
||||
|
|
Loading…
Reference in New Issue