Tidy up ThemeFinder asset precompilation specs

Handle code dependent on Rails config more elegantly.

Signed-off-by: Alex Coles <alex@alexbcoles.com>
pull/1075/head
Alex Coles 11 years ago
parent 01cd4bd924
commit 4bf96157d5
  1. 20
      spec/lib/open_project/themes/theme_finder_spec.rb

@ -89,6 +89,13 @@ module OpenProject
end end
context 'asset precompilation' do context 'asset precompilation' do
around do |example|
old_precompile_config = Rails.application.config.assets.precompile
Rails.application.config.assets.precompile.clear
example.run
Rails.application.config.assets.precompile = old_precompile_config
end
let(:asset_files) { let(:asset_files) {
%w( %w(
adn-bootstrap.css adn-bootstrap.css
@ -98,10 +105,8 @@ module OpenProject
) )
} }
let(:precompile_list) { Rails.application.config.assets.precompile }
let(:precompiled_assets) { let(:precompiled_assets) {
precompile_list = Rails.application.config.assets.precompile
precompile_list = Array(precompile_list.last)
asset_files.map { |asset_path| asset_files.map { |asset_path|
precompile_list.map { |element| precompile_list.map { |element|
element.respond_to?(:call) ? element.call(asset_path) : element element.respond_to?(:call) ? element.call(asset_path) : element
@ -109,12 +114,17 @@ module OpenProject
}.flatten }.flatten
} }
# TODO: gives an error on the whole list
# TODO: remove themes from the list, when clear_themes is called # TODO: remove themes from the list, when clear_themes is called
context 'with no stylesheet manifest registered' do context 'with no stylesheet manifest registered' do
it 'should precompile none of asset files' do
expect(precompiled_assets).to be_none
end
end
context 'with a missing stylesheet manifest registered' do
before do before do
Class.new(Theme) { def stylesheet_manifest; nil; end } Class.new(Theme) { def stylesheet_manifest; 'missing_theme_stylesheet.css'; end }
end end
it 'should precompile none of asset files' do it 'should precompile none of asset files' do

Loading…
Cancel
Save