mirror of https://github.com/mastodon/mastodon
Extend custom CSS cache time with digest paths (#33207)
parent
b3243ef41c
commit
c0264c8013
@ -0,0 +1,18 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
Rails.application.config.to_prepare do
|
||||
custom_css = begin
|
||||
Setting.custom_css
|
||||
rescue ActiveRecord::AdapterError # Running without a database, not migrated, no connection, etc
|
||||
nil
|
||||
end
|
||||
|
||||
if custom_css.present?
|
||||
Rails
|
||||
.cache
|
||||
.write(
|
||||
:setting_digest_custom_css,
|
||||
Digest::SHA256.hexdigest(custom_css)
|
||||
)
|
||||
end
|
||||
end
|
@ -0,0 +1,19 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Custom CSS routes' do
|
||||
describe 'the legacy route' do
|
||||
it 'routes to correct place' do
|
||||
expect(get('/custom.css'))
|
||||
.to route_to('custom_css#show')
|
||||
end
|
||||
end
|
||||
|
||||
describe 'the custom digest route' do
|
||||
it 'routes to correct place' do
|
||||
expect(get('/css/custom-1a2s3d4f.css'))
|
||||
.to route_to('custom_css#show', id: 'custom-1a2s3d4f', format: 'css')
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue