2016-04-01 05:33:25 +08:00
|
|
|
require 'rails_helper'
|
2014-12-23 09:46:10 +08:00
|
|
|
|
|
|
|
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'
|
2015-01-10 01:04:02 +08:00
|
|
|
expect(response.body).to match(/\.a1.*\.a2/m)
|
2014-12-23 09:46:10 +08:00
|
|
|
|
|
|
|
get :show, key: SiteCustomization::ENABLED_KEY, format: :css
|
2015-01-10 01:04:02 +08:00
|
|
|
expect(response.body).to match(/\.b1.*\.b2/m)
|
2014-12-23 09:46:10 +08:00
|
|
|
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'
|
2015-01-10 01:04:02 +08:00
|
|
|
expect(response.body).to match(/\.a1/)
|
2014-12-23 09:46:10 +08:00
|
|
|
|
|
|
|
get :show, key: c.key, format: :css
|
2015-01-10 01:04:02 +08:00
|
|
|
expect(response.body).to match(/\.b1/)
|
2014-12-23 09:46:10 +08:00
|
|
|
end
|
|
|
|
end
|