From 9a4f24f4b55aba023ab05c07277ca31ed87457ae Mon Sep 17 00:00:00 2001 From: Julie Silvestri Date: Tue, 14 Jul 2015 16:13:50 -0400 Subject: [PATCH] Allow no compression for all environments --- lib/sass/rails/railtie.rb | 4 +++- .../config/environments/test.rb | 3 +++ test/sass_rails_test.rb | 10 ++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/sass/rails/railtie.rb b/lib/sass/rails/railtie.rb index 4a14269..949fed1 100644 --- a/lib/sass/rails/railtie.rb +++ b/lib/sass/rails/railtie.rb @@ -68,7 +68,9 @@ class Railtie < ::Rails::Railtie initializer :setup_compression, group: :all do |app| unless Rails.env.development? - app.config.assets.css_compressor ||= :sass + # config.assets.css_compressor may be set to nil in non-dev environments. + # otherwise, the default is sass compression. + app.config.assets.css_compressor = :sass unless app.config.assets.has_key?(:css_compressor) else # Use expanded output instead of the sass default of :nested unless specified app.config.sass.style ||= :expanded diff --git a/test/fixtures/alternate_config_project/config/environments/test.rb b/test/fixtures/alternate_config_project/config/environments/test.rb index f9f3386..055730d 100644 --- a/test/fixtures/alternate_config_project/config/environments/test.rb +++ b/test/fixtures/alternate_config_project/config/environments/test.rb @@ -39,4 +39,7 @@ # Print deprecation notices to the stderr config.active_support.deprecation = :stderr + + # Decide not to use sass compression + config.assets.css_compressor = nil end diff --git a/test/sass_rails_test.rb b/test/sass_rails_test.rb index f21eff3..280b2ee 100644 --- a/test/sass_rails_test.rb +++ b/test/sass_rails_test.rb @@ -76,6 +76,16 @@ class SassRailsTest < Sass::Rails::TestCase end end + test 'sass allows compressor override in test mode' do + within_rails_app 'alternate_config_project' do + runner 'test' do + "puts Rails.application.config.assets.css_compressor.nil?" + end + + assert_equal 'true', $last_output.chomp + end + end + test 'sass defines compressor by default in production mode' do within_rails_app 'scss_project' do runner 'production' do