rack-zippy 1.2.0 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ## 1.2.1 / 2014-07-09
2
+ - Use absolute (not relative) path for default asset_root ([#11](https://github.com/eliotsykes/rack-zippy/issues/11))
3
+
1
4
  ## 1.2.0 / 2014-07-09
2
5
  - Add handling of font files with extensions: woff, woff2, ttf, eot, otf
3
6
  ([#9](https://github.com/eliotsykes/rack-zippy/issues/9))
data/lib/rack-zippy.rb CHANGED
@@ -4,7 +4,7 @@ module Rack
4
4
  module Zippy
5
5
  class AssetServer
6
6
 
7
- def initialize(app, asset_root='public')
7
+ def initialize(app, asset_root=Rails.public_path)
8
8
  @app = app
9
9
  @asset_root = asset_root
10
10
  end
@@ -1,5 +1,5 @@
1
1
  module Rack
2
2
  module Zippy
3
- VERSION = '1.2.0'
3
+ VERSION = '1.2.1'
4
4
  end
5
5
  end
@@ -5,6 +5,7 @@ class Rack::Zippy::AssetServerTest < Test::Unit::TestCase
5
5
 
6
6
  def setup
7
7
  ensure_correct_working_directory
8
+ ::Rails.public_path = Pathname.new("#{Dir.pwd}/public")
8
9
  ::Rails.configuration.assets.compile = false
9
10
  end
10
11
 
@@ -13,11 +14,7 @@ class Rack::Zippy::AssetServerTest < Test::Unit::TestCase
13
14
  end
14
15
 
15
16
  def app
16
- response = 'Up above the streets and houses'
17
- headers = {}
18
- status = 200
19
- rack_app = lambda { |env| [status, headers, response] }
20
- Rack::Zippy::AssetServer.new(rack_app)
17
+ Rack::Zippy::AssetServer.new(create_rack_app)
21
18
  end
22
19
 
23
20
  def test_request_for_non_asset_path_beginning_with_assets_dir_name_bypasses_middleware
@@ -282,10 +279,28 @@ class Rack::Zippy::AssetServerTest < Test::Unit::TestCase
282
279
  assert_underlying_app_responded
283
280
  end
284
281
 
282
+ def test_asset_root_constructor_arg_accepts_string
283
+ asset_server = Rack::Zippy::AssetServer.new(create_rack_app, '/custom/asset/root')
284
+ assert_equal '/custom/asset/root', asset_server.instance_variable_get('@asset_root')
285
+ end
286
+
287
+ def test_default_asset_root_is_rails_public_path
288
+ Rails.public_path = '/unexpected/absolute/path/to/public'
289
+ asset_server = Rack::Zippy::AssetServer.new(create_rack_app)
290
+ assert_equal '/unexpected/absolute/path/to/public', asset_server.instance_variable_get('@asset_root')
291
+ end
292
+
285
293
  private
286
294
 
287
295
  DURATIONS_IN_SECS = {:year => 31536000, :month => 2678400, :day => 86400}.freeze
288
296
 
297
+ def create_rack_app
298
+ status = 200
299
+ headers = {}
300
+ response = 'Up above the streets and houses'
301
+ lambda { |env| [status, headers, response] }
302
+ end
303
+
289
304
  def assert_last_modified(expected)
290
305
  assert_equal expected, last_response.headers['last-modified']
291
306
  end
data/test/test_helper.rb CHANGED
@@ -8,11 +8,21 @@ require 'rack/test'
8
8
 
9
9
  module Rails
10
10
 
11
- @configuration = Struct.new(:assets).new
12
- @configuration.assets = Struct.new(:compile).new
11
+ @@public_path = '/default/path/to/public/set/in/test_helper'
12
+
13
+ @@configuration = Struct.new(:assets).new
14
+ @@configuration.assets = Struct.new(:compile).new
13
15
 
14
16
  def self.configuration
15
- @configuration
17
+ @@configuration
18
+ end
19
+
20
+ def self.public_path
21
+ @@public_path
22
+ end
23
+
24
+ def self.public_path=(path)
25
+ @@public_path = path
16
26
  end
17
27
 
18
28
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-zippy
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -56,7 +56,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
56
56
  version: '0'
57
57
  segments:
58
58
  - 0
59
- hash: 2186381762254847347
59
+ hash: 1496083500993811016
60
60
  required_rubygems_version: !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
@@ -65,7 +65,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
65
65
  version: '0'
66
66
  segments:
67
67
  - 0
68
- hash: 2186381762254847347
68
+ hash: 1496083500993811016
69
69
  requirements: []
70
70
  rubyforge_project:
71
71
  rubygems_version: 1.8.23.2