mirror of
https://github.com/discourse/discourse.git
synced 2025-01-18 18:12:46 +08:00
DEV: load styleguide assets only when needed (#10918)
This commit is contained in:
parent
74de7a49f5
commit
73d207a568
|
@ -34,6 +34,7 @@ const SERVER_SIDE_ONLY = [
|
|||
/^\/admin\/logs\/watched_words\/action\/[^\/]+\/download$/,
|
||||
/^\/pub\//,
|
||||
/^\/invites\//,
|
||||
/^\/styleguide\//,
|
||||
];
|
||||
|
||||
// The amount of height (in pixles) that we factor in when jumpEnd is called so
|
||||
|
|
|
@ -13,3 +13,9 @@ load File.expand_path('../lib/styleguide/engine.rb', __FILE__)
|
|||
Discourse::Application.routes.append do
|
||||
mount ::Styleguide::Engine, at: '/styleguide'
|
||||
end
|
||||
|
||||
after_initialize do
|
||||
register_asset_filter do |type, request|
|
||||
request&.fullpath&.start_with?('/styleguide')
|
||||
end
|
||||
end
|
||||
|
|
24
plugins/styleguide/spec/integration/assets_spec.rb
Normal file
24
plugins/styleguide/spec/integration/assets_spec.rb
Normal file
|
@ -0,0 +1,24 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'Styleguide assets' do
|
||||
before do
|
||||
SiteSetting.styleguide_enabled = true
|
||||
sign_in(Fabricate(:admin))
|
||||
end
|
||||
|
||||
context 'visits homepage' do
|
||||
it 'doesn’t load styleguide assets' do
|
||||
get '/'
|
||||
expect(response.body).to_not include('styleguide')
|
||||
end
|
||||
end
|
||||
|
||||
context 'visits styleguide' do
|
||||
it 'loads styleguide assets' do
|
||||
get '/styleguide'
|
||||
expect(response.body).to include('styleguide')
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue
Block a user