From 5370346c08d740f64060d7c5dd7654a5f91c9bb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Tue, 22 Apr 2014 14:35:42 -0500 Subject: [PATCH] Merge pull request #140 from pomnikita/fix-assets-version assets version doesn't depend on asset host if it's a Proc --- lib/sprockets/railtie.rb | 4 ++-- test/test_railtie.rb | 16 +++++++++++++++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/lib/sprockets/railtie.rb b/lib/sprockets/railtie.rb index 11b8e263..91d82db1 100644 --- a/lib/sprockets/railtie.rb +++ b/lib/sprockets/railtie.rb @@ -74,8 +74,8 @@ def configure(&block) app.assets.version, config.assets.version, config.action_controller.relative_url_root, - config.action_controller.asset_host, - Sprockets::Rails::VERSION, + (config.action_controller.asset_host unless config.action_controller.asset_host.respond_to?(:call)), + Sprockets::Rails::VERSION ].compact.join('-') # Copy config.assets.paths to Sprockets diff --git a/test/test_railtie.rb b/test/test_railtie.rb index 0d0e51e0..8fee7f21 100644 --- a/test/test_railtie.rb +++ b/test/test_railtie.rb @@ -112,7 +112,7 @@ def test_version assert_equal "test-v2-#{Sprockets::Rails::VERSION}", env.version end - def test_version_fragments + def test_version_fragments_with_string_asset_host app.configure do config.assets.version = 'v2' config.action_controller.asset_host = 'http://some-cdn.com' @@ -124,6 +124,20 @@ def test_version_fragments assert_equal "test-v2-some-path-http://some-cdn.com-#{Sprockets::Rails::VERSION}", env.version end + def test_version_fragments_with_proc_asset_host + app.configure do + config.assets.version = 'v2' + config.action_controller.asset_host = ->(path, request) { + 'http://some-cdn.com' + } + config.action_controller.relative_url_root = 'some-path' + end + app.initialize! + + assert env = app.assets + assert_equal "test-v2-some-path-#{Sprockets::Rails::VERSION}", env.version + end + def test_configure app.configure do config.assets.configure do |env|