mirror of
https://github.com/discourse/discourse.git
synced 2024-12-12 10:53:42 +08:00
70bb2aa426
This refactors handling of s3 so it can be specified via GlobalSetting This means that in a multisite environment you can configure s3 uploads without actual sites knowing credentials in s3 It is a critical setting for situations where assets are mirrored to s3.
37 lines
1.3 KiB
Ruby
37 lines
1.3 KiB
Ruby
require 'rails_helper'
|
|
require 'stylesheet/importer'
|
|
|
|
describe Stylesheet::Importer do
|
|
|
|
def compile_css(name)
|
|
Stylesheet::Compiler.compile_asset(name)[0]
|
|
end
|
|
|
|
it "applies CDN to background category images" do
|
|
expect(compile_css("category_backgrounds")).to_not include("background-image")
|
|
|
|
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})}")
|
|
|
|
GlobalSetting.expects(:cdn_url).returns("//awesome.cdn")
|
|
expect(compile_css("category_backgrounds")).to include("body.category-#{category.full_slug}{background-image:url(//awesome.cdn#{background.url})}")
|
|
end
|
|
|
|
it "applies S3 CDN to background category images" do
|
|
SiteSetting.s3_use_iam_profile = true
|
|
SiteSetting.s3_upload_bucket = 'test'
|
|
SiteSetting.s3_region = 'ap-southeast-2'
|
|
SiteSetting.s3_cdn_url = "https://s3.cdn"
|
|
|
|
SiteSetting.enable_s3_uploads = true
|
|
|
|
background = Fabricate(:upload_s3)
|
|
category = Fabricate(:category, uploaded_background: background)
|
|
|
|
expect(compile_css("category_backgrounds")).to include("body.category-#{category.full_slug}{background-image:url(https://s3.cdn/uploads")
|
|
end
|
|
|
|
end
|