heroku-deflater 0.6.2 → 0.6.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 575688520f9c27f3b054344c6963dd158f70011b
4
- data.tar.gz: e4c10c808f9610decf1b3f51fca4815bad411fad
3
+ metadata.gz: e888115a9c0fbd89dc637847bee2ed1ba6831b96
4
+ data.tar.gz: a517faae436b94fb29069ab00278fa6e5be8e42e
5
5
  SHA512:
6
- metadata.gz: cee5e69f39d38afdadb2fe594ee549dd2be04c2fa741e51b7ab47e8ead6b707be3d4e81a7ec150086c3060e035f0bf8f2b7296fe9ecba62dd0f03a55f5e81074
7
- data.tar.gz: 392371202d16856f736a757b8c528db1e6eb7412c99dcf7f1a74d2e465bf166d75b1eea8ba2b3206056c42855428389359b3c7e53aaaf56a2a7d3e9fe734ce82
6
+ metadata.gz: 918d69b7754e30c1774be67c151cf64ae77e131334f06ac763ca5ab74d2c050f1676f3649d167047c40b2e37f5c23d8769095118aca56832cd05a7b2ecb90d10
7
+ data.tar.gz: cb7bf0e6d947e487b0080a925aed940ba65a461ecbc68ff3c4c138e8df2c830a07c69524fa699d77ff3d4b4ec5642508fe17a61daec22fc1cd433140585739b2
data/Gemfile CHANGED
@@ -5,4 +5,6 @@ gem 'rack', '>=1.4.5'
5
5
  group :development do
6
6
  gem "bundler"
7
7
  gem "jeweler"
8
+ gem "rspec"
9
+ gem "rails"
8
10
  end
@@ -1,49 +1,160 @@
1
1
  GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
- addressable (2.3.8)
5
- builder (3.2.2)
4
+ actioncable (5.0.1)
5
+ actionpack (= 5.0.1)
6
+ nio4r (~> 1.2)
7
+ websocket-driver (~> 0.6.1)
8
+ actionmailer (5.0.1)
9
+ actionpack (= 5.0.1)
10
+ actionview (= 5.0.1)
11
+ activejob (= 5.0.1)
12
+ mail (~> 2.5, >= 2.5.4)
13
+ rails-dom-testing (~> 2.0)
14
+ actionpack (5.0.1)
15
+ actionview (= 5.0.1)
16
+ activesupport (= 5.0.1)
17
+ rack (~> 2.0)
18
+ rack-test (~> 0.6.3)
19
+ rails-dom-testing (~> 2.0)
20
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
21
+ actionview (5.0.1)
22
+ activesupport (= 5.0.1)
23
+ builder (~> 3.1)
24
+ erubis (~> 2.7.0)
25
+ rails-dom-testing (~> 2.0)
26
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
27
+ activejob (5.0.1)
28
+ activesupport (= 5.0.1)
29
+ globalid (>= 0.3.6)
30
+ activemodel (5.0.1)
31
+ activesupport (= 5.0.1)
32
+ activerecord (5.0.1)
33
+ activemodel (= 5.0.1)
34
+ activesupport (= 5.0.1)
35
+ arel (~> 7.0)
36
+ activesupport (5.0.1)
37
+ concurrent-ruby (~> 1.0, >= 1.0.2)
38
+ i18n (~> 0.7)
39
+ minitest (~> 5.1)
40
+ tzinfo (~> 1.1)
41
+ addressable (2.5.0)
42
+ public_suffix (~> 2.0, >= 2.0.2)
43
+ arel (7.1.4)
44
+ builder (3.2.3)
45
+ concurrent-ruby (1.0.4)
6
46
  descendants_tracker (0.0.4)
7
47
  thread_safe (~> 0.3, >= 0.3.1)
48
+ diff-lcs (1.3)
49
+ erubis (2.7.0)
8
50
  faraday (0.9.2)
9
51
  multipart-post (>= 1.2, < 3)
10
- git (1.2.9.1)
11
- github_api (0.12.4)
52
+ git (1.3.0)
53
+ github_api (0.11.3)
12
54
  addressable (~> 2.3)
13
- descendants_tracker (~> 0.0.4)
55
+ descendants_tracker (~> 0.0.1)
14
56
  faraday (~> 0.8, < 0.10)
15
- hashie (>= 3.4)
57
+ hashie (>= 1.2)
16
58
  multi_json (>= 1.7.5, < 2.0)
17
- nokogiri (~> 1.6.6)
59
+ nokogiri (~> 1.6.0)
18
60
  oauth2
19
- hashie (3.4.3)
61
+ globalid (0.3.7)
62
+ activesupport (>= 4.1.0)
63
+ hashie (3.4.6)
20
64
  highline (1.7.8)
21
- jeweler (2.0.1)
65
+ i18n (0.7.0)
66
+ jeweler (2.3.3)
22
67
  builder
23
68
  bundler (>= 1.0)
24
69
  git (>= 1.2.5)
25
- github_api
70
+ github_api (~> 0.11.0)
26
71
  highline (>= 1.6.15)
27
72
  nokogiri (>= 1.5.10)
73
+ psych (~> 2.2)
28
74
  rake
29
75
  rdoc
30
- jwt (1.5.2)
31
- mini_portile (0.6.2)
32
- multi_json (1.11.2)
33
- multi_xml (0.5.5)
76
+ semver2
77
+ jwt (1.5.6)
78
+ loofah (2.0.3)
79
+ nokogiri (>= 1.5.9)
80
+ mail (2.6.4)
81
+ mime-types (>= 1.16, < 4)
82
+ method_source (0.8.2)
83
+ mime-types (3.1)
84
+ mime-types-data (~> 3.2015)
85
+ mime-types-data (3.2016.0521)
86
+ mini_portile2 (2.1.0)
87
+ minitest (5.10.1)
88
+ multi_json (1.12.1)
89
+ multi_xml (0.6.0)
34
90
  multipart-post (2.0.0)
35
- nokogiri (1.6.6.2)
36
- mini_portile (~> 0.6.0)
37
- oauth2 (1.0.0)
38
- faraday (>= 0.8, < 0.10)
91
+ nio4r (1.2.1)
92
+ nokogiri (1.6.8.1)
93
+ mini_portile2 (~> 2.1.0)
94
+ oauth2 (1.3.0)
95
+ faraday (>= 0.8, < 0.11)
39
96
  jwt (~> 1.0)
40
97
  multi_json (~> 1.3)
41
98
  multi_xml (~> 0.5)
42
- rack (~> 1.2)
43
- rack (1.6.4)
44
- rake (10.4.2)
45
- rdoc (4.2.0)
99
+ rack (>= 1.2, < 3)
100
+ psych (2.2.2)
101
+ public_suffix (2.0.5)
102
+ rack (2.0.1)
103
+ rack-test (0.6.3)
104
+ rack (>= 1.0)
105
+ rails (5.0.1)
106
+ actioncable (= 5.0.1)
107
+ actionmailer (= 5.0.1)
108
+ actionpack (= 5.0.1)
109
+ actionview (= 5.0.1)
110
+ activejob (= 5.0.1)
111
+ activemodel (= 5.0.1)
112
+ activerecord (= 5.0.1)
113
+ activesupport (= 5.0.1)
114
+ bundler (>= 1.3.0, < 2.0)
115
+ railties (= 5.0.1)
116
+ sprockets-rails (>= 2.0.0)
117
+ rails-dom-testing (2.0.2)
118
+ activesupport (>= 4.2.0, < 6.0)
119
+ nokogiri (~> 1.6)
120
+ rails-html-sanitizer (1.0.3)
121
+ loofah (~> 2.0)
122
+ railties (5.0.1)
123
+ actionpack (= 5.0.1)
124
+ activesupport (= 5.0.1)
125
+ method_source
126
+ rake (>= 0.8.7)
127
+ thor (>= 0.18.1, < 2.0)
128
+ rake (12.0.0)
129
+ rdoc (5.0.0)
130
+ rspec (3.5.0)
131
+ rspec-core (~> 3.5.0)
132
+ rspec-expectations (~> 3.5.0)
133
+ rspec-mocks (~> 3.5.0)
134
+ rspec-core (3.5.4)
135
+ rspec-support (~> 3.5.0)
136
+ rspec-expectations (3.5.0)
137
+ diff-lcs (>= 1.2.0, < 2.0)
138
+ rspec-support (~> 3.5.0)
139
+ rspec-mocks (3.5.0)
140
+ diff-lcs (>= 1.2.0, < 2.0)
141
+ rspec-support (~> 3.5.0)
142
+ rspec-support (3.5.0)
143
+ semver2 (3.4.2)
144
+ sprockets (3.7.1)
145
+ concurrent-ruby (~> 1.0)
146
+ rack (> 1, < 3)
147
+ sprockets-rails (3.2.0)
148
+ actionpack (>= 4.0)
149
+ activesupport (>= 4.0)
150
+ sprockets (>= 3.0.0)
151
+ thor (0.19.4)
46
152
  thread_safe (0.3.5)
153
+ tzinfo (1.2.2)
154
+ thread_safe (~> 0.1)
155
+ websocket-driver (0.6.5)
156
+ websocket-extensions (>= 0.1.0)
157
+ websocket-extensions (0.1.2)
47
158
 
48
159
  PLATFORMS
49
160
  ruby
@@ -52,3 +163,8 @@ DEPENDENCIES
52
163
  bundler
53
164
  jeweler
54
165
  rack (>= 1.4.5)
166
+ rails
167
+ rspec
168
+
169
+ BUNDLED WITH
170
+ 1.14.2
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.6.2
1
+ 0.6.3
@@ -2,18 +2,18 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: heroku-deflater 0.6.2 ruby lib
5
+ # stub: heroku-deflater 0.6.3 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
- s.name = "heroku-deflater"
9
- s.version = "0.6.2"
8
+ s.name = "heroku-deflater".freeze
9
+ s.version = "0.6.3"
10
10
 
11
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
- s.require_paths = ["lib"]
13
- s.authors = ["Roman Shterenzon"]
14
- s.date = "2015-11-03"
15
- s.description = "Deflate assets on heroku"
16
- s.email = "romanbsd@yahoo.com"
11
+ s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
12
+ s.require_paths = ["lib".freeze]
13
+ s.authors = ["Roman Shterenzon".freeze]
14
+ s.date = "2017-01-25"
15
+ s.description = "Deflate assets on heroku".freeze
16
+ s.email = "romanbsd@yahoo.com".freeze
17
17
  s.extra_rdoc_files = [
18
18
  "LICENSE.txt",
19
19
  "README.md"
@@ -28,9 +28,11 @@ Gem::Specification.new do |s|
28
28
  "VERSION",
29
29
  "heroku-deflater.gemspec",
30
30
  "lib/heroku-deflater.rb",
31
+ "lib/heroku-deflater/cache_control_manager.rb",
31
32
  "lib/heroku-deflater/railtie.rb",
32
33
  "lib/heroku-deflater/serve_zipped_assets.rb",
33
34
  "lib/heroku-deflater/skip_binary.rb",
35
+ "spec/cache_control_manager_spec.rb",
34
36
  "spec/fixtures/assets/spec.js",
35
37
  "spec/fixtures/assets/spec.js.gz",
36
38
  "spec/fixtures/assets/spec2.js",
@@ -38,27 +40,33 @@ Gem::Specification.new do |s|
38
40
  "spec/serve_zipped_assets_spec.rb",
39
41
  "spec/skip_binary_spec.rb"
40
42
  ]
41
- s.homepage = "http://github.com/romanbsd/heroku-deflater"
42
- s.licenses = ["MIT"]
43
- s.rubygems_version = "2.4.6"
44
- s.summary = "Deflate assets on heroku"
43
+ s.homepage = "http://github.com/romanbsd/heroku-deflater".freeze
44
+ s.licenses = ["MIT".freeze]
45
+ s.rubygems_version = "2.6.8".freeze
46
+ s.summary = "Deflate assets on heroku".freeze
45
47
 
46
48
  if s.respond_to? :specification_version then
47
49
  s.specification_version = 4
48
50
 
49
51
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
50
- s.add_runtime_dependency(%q<rack>, [">= 1.4.5"])
51
- s.add_development_dependency(%q<bundler>, [">= 0"])
52
- s.add_development_dependency(%q<jeweler>, [">= 0"])
52
+ s.add_runtime_dependency(%q<rack>.freeze, [">= 1.4.5"])
53
+ s.add_development_dependency(%q<bundler>.freeze, [">= 0"])
54
+ s.add_development_dependency(%q<jeweler>.freeze, [">= 0"])
55
+ s.add_development_dependency(%q<rspec>.freeze, [">= 0"])
56
+ s.add_development_dependency(%q<rails>.freeze, [">= 0"])
53
57
  else
54
- s.add_dependency(%q<rack>, [">= 1.4.5"])
55
- s.add_dependency(%q<bundler>, [">= 0"])
56
- s.add_dependency(%q<jeweler>, [">= 0"])
58
+ s.add_dependency(%q<rack>.freeze, [">= 1.4.5"])
59
+ s.add_dependency(%q<bundler>.freeze, [">= 0"])
60
+ s.add_dependency(%q<jeweler>.freeze, [">= 0"])
61
+ s.add_dependency(%q<rspec>.freeze, [">= 0"])
62
+ s.add_dependency(%q<rails>.freeze, [">= 0"])
57
63
  end
58
64
  else
59
- s.add_dependency(%q<rack>, [">= 1.4.5"])
60
- s.add_dependency(%q<bundler>, [">= 0"])
61
- s.add_dependency(%q<jeweler>, [">= 0"])
65
+ s.add_dependency(%q<rack>.freeze, [">= 1.4.5"])
66
+ s.add_dependency(%q<bundler>.freeze, [">= 0"])
67
+ s.add_dependency(%q<jeweler>.freeze, [">= 0"])
68
+ s.add_dependency(%q<rspec>.freeze, [">= 0"])
69
+ s.add_dependency(%q<rails>.freeze, [">= 0"])
62
70
  end
63
71
  end
64
72
 
@@ -0,0 +1,39 @@
1
+ module HerokuDeflater
2
+ class CacheControlManager
3
+ DEFAULT_MAX_AGE = '86400'.freeze
4
+ attr_reader :app, :max_age
5
+
6
+ def initialize(app)
7
+ @app = app
8
+ @max_age = DEFAULT_MAX_AGE
9
+ end
10
+
11
+ def setup_max_age(max_age)
12
+ @max_age = max_age
13
+ if rails_version_5?
14
+ app.config.public_file_server.headers ||= {}
15
+ app.config.public_file_server.headers['Cache-Control'] = cache_control
16
+ else
17
+ app.config.static_cache_control = cache_control
18
+ end
19
+ end
20
+
21
+ def cache_control_headers
22
+ if rails_version_5?
23
+ { 'Cache-Control' => cache_control }
24
+ else
25
+ cache_control
26
+ end
27
+ end
28
+
29
+ private
30
+
31
+ def rails_version_5?
32
+ Rails::VERSION::MAJOR >= 5
33
+ end
34
+
35
+ def cache_control
36
+ @_cache_control ||= "public, max-age=#{max_age}"
37
+ end
38
+ end
39
+ end
@@ -1,6 +1,7 @@
1
1
  require 'rack/deflater'
2
2
  require 'heroku-deflater/skip_binary'
3
3
  require 'heroku-deflater/serve_zipped_assets'
4
+ require 'heroku-deflater/cache_control_manager'
4
5
 
5
6
  module HerokuDeflater
6
7
  class Railtie < Rails::Railtie
@@ -8,13 +9,18 @@ module HerokuDeflater
8
9
  app.middleware.insert_before ActionDispatch::Static, Rack::Deflater
9
10
  app.middleware.insert_before ActionDispatch::Static, HerokuDeflater::SkipBinary
10
11
  app.middleware.insert_before Rack::Deflater, HerokuDeflater::ServeZippedAssets,
11
- app.paths['public'].first, app.config.assets.prefix, app.config.static_cache_control
12
+ app.paths['public'].first, app.config.assets.prefix, self.class.cache_control_manager(app)
12
13
  end
13
14
 
14
15
  # Set default Cache-Control headers to one week.
15
16
  # The configuration block in config/application.rb overrides this.
16
17
  config.before_configuration do |app|
17
- app.config.static_cache_control = 'public, max-age=604800'
18
+ cache_control = cache_control_manager(app)
19
+ cache_control.setup_max_age(86400)
20
+ end
21
+
22
+ def self.cache_control_manager(app)
23
+ @_cache_control_manager ||= CacheControlManager.new(app)
18
24
  end
19
25
  end
20
26
  end
@@ -9,11 +9,14 @@ require 'action_dispatch/middleware/static'
9
9
 
10
10
  module HerokuDeflater
11
11
  class ServeZippedAssets
12
- def initialize(app, root, assets_path, cache_control=nil)
12
+ def initialize(app, root, assets_path, cache_control_manager)
13
13
  @app = app
14
14
  @assets_path = assets_path.chomp('/') + '/'
15
- cache_control = {headers: {'Cache-Control' => cache_control}} if Rails::VERSION::MAJOR >= 5 && cache_control.is_a?(String)
16
- @file_handler = ActionDispatch::FileHandler.new(root, cache_control)
15
+ if rails_version_5?
16
+ @file_handler = ActionDispatch::FileHandler.new(root, headers: cache_control_manager.cache_control_headers)
17
+ else
18
+ @file_handler = ActionDispatch::FileHandler.new(root, cache_control_manager.cache_control_headers)
19
+ end
17
20
  end
18
21
 
19
22
  def call(env)
@@ -50,5 +53,10 @@ module HerokuDeflater
50
53
 
51
54
  @app.call(env)
52
55
  end
56
+
57
+ private
58
+ def rails_version_5?
59
+ Rails::VERSION::MAJOR >= 5
60
+ end
53
61
  end
54
62
  end
@@ -21,7 +21,7 @@ module HerokuDeflater
21
21
  content_type = headers['Content-Type']
22
22
  cache_control = headers['Cache-Control'].to_s.downcase
23
23
 
24
- unless cache_control.include?('no-transform') or WHITELIST.any? { |type| type === content_type }
24
+ unless cache_control.include?('no-transform') || WHITELIST.any? { |type| type === content_type }
25
25
  if cache_control.empty?
26
26
  headers['Cache-Control'] = 'no-transform'
27
27
  else
@@ -0,0 +1,68 @@
1
+ require 'heroku-deflater/cache_control_manager'
2
+ require 'rails'
3
+
4
+ describe HerokuDeflater::CacheControlManager do
5
+ class Rails5App
6
+ def config
7
+ @_config ||= Config.new
8
+ end
9
+
10
+ class Config
11
+ attr_accessor :headers
12
+
13
+ def initialize
14
+ @headers = {}
15
+ end
16
+
17
+ def public_file_server
18
+ self
19
+ end
20
+ end
21
+ end
22
+
23
+ class Rails4App
24
+ def config
25
+ @_config ||= Config.new
26
+ end
27
+
28
+ class Config
29
+ attr_accessor :static_cache_control
30
+ end
31
+ end
32
+
33
+ context 'Rails 4.x and below' do
34
+ let(:app) { Rails4App.new }
35
+
36
+ subject { described_class.new(app) }
37
+ before do
38
+ allow(subject).to receive(:rails_version_5?).and_return(false)
39
+ subject.setup_max_age(86400)
40
+ end
41
+
42
+ it 'sets max age for static_cache_control config option' do
43
+ expect(app.config.static_cache_control).to eq('public, max-age=86400')
44
+ end
45
+
46
+ it 'cache_control_headers returns cache control option' do
47
+ expect(subject.cache_control_headers).to eq('public, max-age=86400')
48
+ end
49
+ end
50
+
51
+ context 'Rails 5' do
52
+ let(:app) { Rails5App.new }
53
+
54
+ subject { described_class.new(app) }
55
+ before do
56
+ allow(subject).to receive(:rails_version_5?).and_return(true)
57
+ subject.setup_max_age(86400)
58
+ end
59
+
60
+ it 'sets max age for public_file_server config option' do
61
+ expect(app.config.public_file_server.headers['Cache-Control']).to eq('public, max-age=86400')
62
+ end
63
+
64
+ it 'cache_control_headers returns hash cache control headers' do
65
+ expect(subject.cache_control_headers).to eq({'Cache-Control' =>'public, max-age=86400'})
66
+ end
67
+ end
68
+ end
@@ -1,6 +1,7 @@
1
1
  require 'rack/mock'
2
2
  require 'rack/static'
3
3
  require 'heroku-deflater/serve_zipped_assets'
4
+ require 'heroku-deflater/cache_control_manager'
4
5
 
5
6
  describe HerokuDeflater::ServeZippedAssets do
6
7
  def process(path, accept_encoding = 'compress, gzip, deflate')
@@ -12,49 +13,68 @@ describe HerokuDeflater::ServeZippedAssets do
12
13
  def app
13
14
  @app ||= begin
14
15
  root_path = File.expand_path('../fixtures', __FILE__)
15
- cache_control = 'public, max-age=86400'
16
+ cache_control_manager = HerokuDeflater::CacheControlManager.new(nil)
16
17
  mock = lambda { |env| [404, {'X-Cascade' => 'pass'}, []] }
17
- described_class.new(mock, root_path, '/assets', cache_control)
18
+ described_class.new(mock, root_path, '/assets', cache_control_manager)
18
19
  end
19
20
  end
20
21
 
21
- it 'does nothing for clients which do not want gzip' do
22
- status, headers, body = process('/assets/spec.js', nil)
23
- status.should eq(404)
24
- end
22
+ shared_examples_for 'ServeZippedAssets' do
25
23
 
26
- it 'handles the pre-gzipped assets' do
27
- status, headers, body = process('/assets/spec.js')
28
- status.should eq(200)
29
- end
24
+ it 'does nothing for clients which do not want gzip' do
25
+ status, headers, body = process('/assets/spec.js', nil)
26
+ expect(status).to eq(404)
27
+ end
30
28
 
31
- it 'has correct content type' do
32
- status, headers, body = process('/assets/spec.js')
33
- headers['Content-Type'].should eq('application/javascript')
34
- end
29
+ it 'handles the pre-gzipped assets' do
30
+ status, headers, body = process('/assets/spec.js')
31
+ expect(status).to eq(200)
32
+ end
35
33
 
36
- it 'has correct content encoding' do
37
- status, headers, body = process('/assets/spec.js')
38
- headers['Content-Encoding'].should eq('gzip')
39
- end
34
+ it 'has correct content type' do
35
+ status, headers, body = process('/assets/spec.js')
36
+ expect(headers['Content-Type']).to eq('application/javascript')
37
+ end
40
38
 
41
- it 'has correct content length' do
42
- status, headers, body = process('/assets/spec.js')
43
- headers['Content-Length'].should eq('86')
44
- end
39
+ it 'has correct content encoding' do
40
+ status, headers, body = process('/assets/spec.js')
41
+ expect(headers['Content-Encoding']).to eq('gzip')
42
+ end
43
+
44
+ it 'has correct content length' do
45
+ status, headers, body = process('/assets/spec.js')
46
+ expect(headers['Content-Length']).to eq('86')
47
+ end
48
+
49
+ it 'has correct cache control' do
50
+ status, headers, body = process('/assets/spec.js')
51
+ expect(headers['Cache-Control']).to eq('public, max-age=86400')
52
+ end
53
+
54
+ it 'does not serve non-gzipped assets' do
55
+ status, headers, body = process('/assets/spec2.js')
56
+ expect(status).to eq(404)
57
+ end
45
58
 
46
- it 'has correct cache control' do
47
- status, headers, body = process('/assets/spec.js')
48
- headers['Cache-Control'].should eq('public, max-age=86400')
59
+ it 'does not serve anything from non-asset directories' do
60
+ status, headers, body = process('/non-assets/spec.js')
61
+ expect(status).to eq(404)
62
+ end
49
63
  end
50
64
 
51
- it 'does not serve non-gzipped assets' do
52
- status, headers, body = process('/assets/spec2.js')
53
- status.should eq(404)
65
+ describe 'Rais 4.x' do
66
+ before do
67
+ allow(app).to receive(:rails_version_5?) { false }
68
+ end
69
+
70
+ it_behaves_like 'ServeZippedAssets'
54
71
  end
55
72
 
56
- it 'does not serve anything from non-asset directories' do
57
- status, headers, body = process('/non-assets/spec.js')
58
- status.should eq(404)
73
+ describe 'Rais 5.x' do
74
+ before do
75
+ allow(app).to receive(:rails_version_5?) { true }
76
+ end
77
+
78
+ it_behaves_like 'ServeZippedAssets'
59
79
  end
60
80
  end
@@ -15,7 +15,7 @@ describe HerokuDeflater::SkipBinary do
15
15
  it "forbids compressing of binary types" do
16
16
  %w[application/gzip application/pdf image/jpeg].each do |type|
17
17
  headers = process(type)
18
- headers['Cache-Control'].to_s.should include('no-transform')
18
+ expect(headers['Cache-Control'].to_s).to include('no-transform')
19
19
  end
20
20
  end
21
21
 
@@ -23,18 +23,18 @@ describe HerokuDeflater::SkipBinary do
23
23
  %w[text/plain text/html application/json application/javascript
24
24
  application/rss+xml].each do |type|
25
25
  headers = process(type)
26
- headers['Cache-Control'].to_s.should_not include('no-transform')
26
+ expect(headers['Cache-Control'].to_s).not_to include('no-transform')
27
27
  end
28
28
  end
29
29
 
30
30
  it "adds to existing headers" do
31
31
  headers = process('image/gif', 'Cache-Control' => 'public')
32
- headers['Cache-Control'].should eq('public, no-transform')
32
+ expect(headers['Cache-Control']).to eq('public, no-transform')
33
33
  end
34
34
 
35
35
  it "doesn't add 'no-transform' if it's already present" do
36
36
  headers = process('image/gif', 'Cache-Control' => 'public, no-transform')
37
- headers['Cache-Control'].should eq('public, no-transform')
37
+ expect(headers['Cache-Control']).to eq('public, no-transform')
38
38
  end
39
39
 
40
40
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: heroku-deflater
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.2
4
+ version: 0.6.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roman Shterenzon
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-03 00:00:00.000000000 Z
11
+ date: 2017-01-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
@@ -52,6 +52,34 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rails
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
55
83
  description: Deflate assets on heroku
56
84
  email: romanbsd@yahoo.com
57
85
  executables: []
@@ -69,9 +97,11 @@ files:
69
97
  - VERSION
70
98
  - heroku-deflater.gemspec
71
99
  - lib/heroku-deflater.rb
100
+ - lib/heroku-deflater/cache_control_manager.rb
72
101
  - lib/heroku-deflater/railtie.rb
73
102
  - lib/heroku-deflater/serve_zipped_assets.rb
74
103
  - lib/heroku-deflater/skip_binary.rb
104
+ - spec/cache_control_manager_spec.rb
75
105
  - spec/fixtures/assets/spec.js
76
106
  - spec/fixtures/assets/spec.js.gz
77
107
  - spec/fixtures/assets/spec2.js
@@ -98,7 +128,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
98
128
  version: '0'
99
129
  requirements: []
100
130
  rubyforge_project:
101
- rubygems_version: 2.4.6
131
+ rubygems_version: 2.6.8
102
132
  signing_key:
103
133
  specification_version: 4
104
134
  summary: Deflate assets on heroku