Skip to content

Commit 67c8162

Browse files
committed
Allow gzip to be disabled from Rails configuration.
1 parent 4f4b387 commit 67c8162

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

lib/sprockets/railtie.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ def configure(&block)
112112
config.assets.compile = true
113113
config.assets.digest = true
114114
config.assets.cache_limit = 50.megabytes
115+
config.assets.gzip = true
115116

116117
config.assets.configure do |env|
117118
config.assets.paths.each { |path| env.append_path(path) }
@@ -144,6 +145,10 @@ def configure(&block)
144145
env.version = config.assets.version
145146
end
146147

148+
config.assets.configure do |env|
149+
env.gzip = config.assets.gzip
150+
end
151+
147152
rake_tasks do |app|
148153
require 'sprockets/rails/task'
149154
Sprockets::Rails::Task.new(app)

test/test_railtie.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,23 @@ def test_custom_compressors
165165
assert_equal compressor, env.css_compressor
166166
end
167167

168+
def test_default_gzip_config
169+
app.initialize!
170+
171+
assert env = app.assets
172+
assert_equal true, env.gzip?
173+
end
174+
175+
def test_gzip_config
176+
app.configure do
177+
config.assets.gzip = false
178+
end
179+
app.initialize!
180+
181+
assert env = app.assets
182+
assert_equal false, env.gzip?
183+
end
184+
168185
def test_version
169186
app.configure do
170187
config.assets.version = 'v2'

0 commit comments

Comments
 (0)