mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 22:43:33 +08:00
FEATURE: more than 1 site customization can be enabled at once
FIX: more robust site customizations Rewrote site customization to use distributed cache and a much cleaner css delivery mechanism
This commit is contained in:
45
spec/controllers/site_customizations_controller_spec.rb
Normal file
45
spec/controllers/site_customizations_controller_spec.rb
Normal file
@ -0,0 +1,45 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe SiteCustomizationsController do
|
||||
|
||||
before do
|
||||
SiteCustomization.clear_cache!
|
||||
end
|
||||
|
||||
it 'can deliver enabled css' do
|
||||
SiteCustomization.create!(name: '1',
|
||||
user_id: -1,
|
||||
enabled: true,
|
||||
mobile_stylesheet: '.a1{margin: 1px;}',
|
||||
stylesheet: '.b1{margin: 1px;}'
|
||||
)
|
||||
|
||||
SiteCustomization.create!(name: '2',
|
||||
user_id: -1,
|
||||
enabled: true,
|
||||
mobile_stylesheet: '.a2{margin: 1px;}',
|
||||
stylesheet: '.b2{margin: 1px;}'
|
||||
)
|
||||
|
||||
get :show, key: SiteCustomization::ENABLED_KEY, format: :css, target: 'mobile'
|
||||
response.body.should =~ /\.a1.*\.a2/m
|
||||
|
||||
get :show, key: SiteCustomization::ENABLED_KEY, format: :css
|
||||
response.body.should =~ /\.b1.*\.b2/m
|
||||
end
|
||||
|
||||
it 'can deliver specific css' do
|
||||
c = SiteCustomization.create!(name: '1',
|
||||
user_id: -1,
|
||||
enabled: true,
|
||||
mobile_stylesheet: '.a1{margin: 1px;}',
|
||||
stylesheet: '.b1{margin: 1px;}'
|
||||
)
|
||||
|
||||
get :show, key: c.key, format: :css, target: 'mobile'
|
||||
response.body.should =~ /\.a1/
|
||||
|
||||
get :show, key: c.key, format: :css
|
||||
response.body.should =~ /\.b1/
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user