mirror of
https://github.com/discourse/discourse.git
synced 2024-12-02 11:43:39 +08:00
decf1f27cf
* Phase 0 for user-selectable theme components - Drops `key` column from the `themes` table - Drops `theme_key` column from the `user_options` table - Adds `theme_ids` (array of ints default []) column to the `user_options` table and migrates data from `theme_key` to the new column. - Removes the `default_theme_key` site setting and adds `default_theme_id` instead. - Replaces `theme_key` cookie with a new one called `theme_ids` - no longer need Theme.settings_for_client
59 lines
1.7 KiB
Ruby
59 lines
1.7 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 "/stylesheets/desktop_rtl_#{digest}.css"
|
|
expect(response.status).to eq(200)
|
|
|
|
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 "/stylesheets/desktop_rtl_#{digest}.css"
|
|
expect(response.status).to eq(200)
|
|
|
|
# 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.id)
|
|
builder.compile
|
|
|
|
`rm #{Stylesheet::Manager.cache_fullpath}/*`
|
|
|
|
get "/stylesheets/#{builder.stylesheet_filename.sub(".css", "")}.css"
|
|
|
|
expect(response.status).to eq(200)
|
|
|
|
get "/stylesheets/#{builder.stylesheet_filename_no_digest.sub(".css", "")}.css"
|
|
|
|
expect(response.status).to eq(200)
|
|
|
|
builder = Stylesheet::Manager.new(:desktop_theme, theme.id)
|
|
builder.compile
|
|
|
|
`rm #{Stylesheet::Manager.cache_fullpath}/*`
|
|
|
|
get "/stylesheets/#{builder.stylesheet_filename.sub(".css", "")}.css"
|
|
|
|
expect(response.status).to eq(200)
|
|
|
|
get "/stylesheets/#{builder.stylesheet_filename_no_digest.sub(".css", "")}.css"
|
|
|
|
expect(response.status).to eq(200)
|
|
end
|
|
end
|