discourse/spec/controllers/stylesheets_controller_spec.rb
Sam 89ad2b5900 DEV: Rails 5.2 upgrade and global gem upgrade
This updates tests to use latest rails 5 practice
and updates ALL dependencies that could be updated

Performance testing shows that performance has not regressed
if anything it is marginally faster now.
2018-06-07 14:21:33 +10:00

71 lines
1.8 KiB
Ruby

require 'rails_helper'
describe StylesheetsController do
it 'can survive cache miss' do
StylesheetCache.destroy_all
builder = Stylesheet::Manager.new('desktop_rtl', nil)
builder.compile
digest = StylesheetCache.first.digest
StylesheetCache.destroy_all
get :show, params: { name: "desktop_rtl_#{digest}" }, format: :json
expect(response).to be_successful
cached = StylesheetCache.first
expect(cached.target).to eq 'desktop_rtl'
expect(cached.digest).to eq digest
# tmp folder destruction and cached
`rm #{Stylesheet::Manager.cache_fullpath}/*`
get :show, params: { name: "desktop_rtl_#{digest}" }, format: :json
expect(response).to be_successful
# there is an edge case which is ... disk and db cache is nuked, very unlikely to happen
end
it 'can lookup theme specific css' do
scheme = ColorScheme.create_from_base(name: "testing", colors: [])
theme = Theme.create!(name: "test", color_scheme_id: scheme.id, user_id: -1)
builder = Stylesheet::Manager.new(:desktop, theme.key)
builder.compile
`rm #{Stylesheet::Manager.cache_fullpath}/*`
get :show, params: {
name: builder.stylesheet_filename.sub(".css", "")
}, format: :json
expect(response).to be_successful
get :show, params: {
name: builder.stylesheet_filename_no_digest.sub(".css", "")
}, format: :json
expect(response).to be_successful
builder = Stylesheet::Manager.new(:desktop_theme, theme.key)
builder.compile
`rm #{Stylesheet::Manager.cache_fullpath}/*`
get :show, params: {
name: builder.stylesheet_filename.sub(".css", "")
}, format: :json
expect(response).to be_successful
get :show, params: {
name: builder.stylesheet_filename_no_digest.sub(".css", "")
}, format: :json
expect(response).to be_successful
end
end