Skip to content

Commit

Permalink
Merge pull request rails#140 from pomnikita/fix-assets-version
Browse files Browse the repository at this point in the history
assets version doesn't depend on asset host if it's a Proc
  • Loading branch information
rafaelfranca authored and rossta committed Jul 24, 2014
1 parent d4682db commit 177c184
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/sprockets/railtie.rb
Expand Up @@ -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
Expand Down
16 changes: 15 additions & 1 deletion test/test_railtie.rb
Expand Up @@ -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'
Expand All @@ -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|
Expand Down

0 comments on commit 177c184

Please sign in to comment.