add spec for brotli controller, ensure cached correctly

This commit is contained in:
Sam 2016-12-05 16:08:36 +11:00
parent 8a98d617df
commit dc66f6681a
2 changed files with 14 additions and 0 deletions

View File

@ -145,6 +145,8 @@ class StaticController < ApplicationController
raise Discourse::NotFound
end
expires_in 1.year, public: true, must_revalidate: false
if File.exists?(path)
send_file(path, opts)
else

View File

@ -2,6 +2,18 @@ require 'rails_helper'
describe StaticController do
context 'brotli_asset' do
it 'has correct headers for brotli assets' do
FileUtils.mkdir_p(Rails.root + "public/assets/")
File.write(Rails.root + "public/assets/test.js.br", 'fake brotli file')
get :brotli_asset, path: 'test.js'
expect(response.status).to eq(200)
expect(response.headers["Cache-Control"]).to match(/public/)
end
end
context 'show' do
before do
post = create_post