2015-05-21 21:21:16 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe StylesheetsController do
|
|
|
|
|
|
|
|
it 'can survive cache miss' do
|
|
|
|
|
|
|
|
StylesheetCache.destroy_all
|
2015-05-23 01:25:05 -04:00
|
|
|
builder = DiscourseStylesheets.new('desktop_rtl')
|
|
|
|
builder.compile
|
2015-05-23 01:39:44 -04:00
|
|
|
builder.ensure_digestless_file
|
2015-05-23 01:25:05 -04:00
|
|
|
|
|
|
|
digest = StylesheetCache.first.digest
|
|
|
|
StylesheetCache.destroy_all
|
2015-05-21 21:21:16 -04:00
|
|
|
|
|
|
|
# digestless
|
|
|
|
get :show, name: 'desktop_rtl'
|
|
|
|
expect(response).to be_success
|
|
|
|
|
2015-05-23 01:25:05 -04:00
|
|
|
StylesheetCache.destroy_all
|
|
|
|
|
|
|
|
get :show, name: "desktop_rtl_#{digest}"
|
|
|
|
expect(response).to be_success
|
|
|
|
|
|
|
|
cached = StylesheetCache.first
|
|
|
|
expect(cached.target).to eq 'desktop_rtl'
|
|
|
|
expect(cached.digest).to eq digest
|
|
|
|
|
2015-05-21 21:21:16 -04:00
|
|
|
# tmp folder destruction and cached
|
|
|
|
`rm #{DiscourseStylesheets.cache_fullpath}/*`
|
|
|
|
|
|
|
|
get :show, name: 'desktop_rtl'
|
|
|
|
expect(response).to be_success
|
|
|
|
|
2015-05-23 01:25:05 -04:00
|
|
|
get :show, name: "desktop_rtl_#{digest}"
|
|
|
|
expect(response).to be_success
|
|
|
|
|
2015-05-21 21:21:16 -04:00
|
|
|
# there is an edge case which is ... disk and db cache is nuked, very unlikely to happen
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|