Skip to content

Commit 8332e53

Browse files
committed
Merge pull request #316 from rails/fix-precopile-checker-with-bundle-files
Fix the precompile checker with bundle files
2 parents f8eafb7 + a8f13de commit 8332e53

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

lib/sprockets/rails/helper.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -313,15 +313,15 @@ def asset_path(path, digest, allow_non_precompiled = false)
313313

314314
# Otherwise, ask the Sprockets environment whether the asset exists
315315
# and check whether it's also precompiled for production deploys.
316-
elsif find_asset(path)
317-
raise_unless_precompiled_asset path unless allow_non_precompiled
316+
elsif asset = find_asset(path)
317+
raise_unless_precompiled_asset asset.logical_path unless allow_non_precompiled
318318
path
319319
end
320320
end
321321

322322
def digest_path(path, allow_non_precompiled = false)
323323
if asset = find_asset(path)
324-
raise_unless_precompiled_asset path unless allow_non_precompiled
324+
raise_unless_precompiled_asset asset.logical_path unless allow_non_precompiled
325325
asset.digest_path
326326
end
327327
end

test/fixtures/manifest.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@
77
//= link file1.js
88
//= link file2.css
99
//= link file2.js
10+
//= link bundle.js

test/test_helper.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -803,6 +803,11 @@ def test_asset_environment_reference_is_cached
803803
end
804804

805805
class PrecompiledAssetHelperTest < HelperTest
806+
def setup
807+
super
808+
@bundle_js_name = '/assets/bundle.js'
809+
end
810+
806811
def test_javascript_precompile
807812
assert_raises(Sprockets::Rails::Helper::AssetNotPrecompiled) do
808813
@view.javascript_include_tag("not_precompiled")
@@ -814,11 +819,17 @@ def test_stylesheet_precompile
814819
@view.stylesheet_link_tag("not_precompiled")
815820
end
816821
end
822+
823+
def test_index_files
824+
assert_dom_equal %(<script src="#{@bundle_js_name}"></script>),
825+
@view.javascript_include_tag("bundle")
826+
end
817827
end
818828

819829
class PrecompiledDebugAssetHelperTest < PrecompiledAssetHelperTest
820830
def setup
821831
super
822832
@view.debug_assets = true
833+
@bundle_js_name = '/assets/bundle/index.self.js?body=1'
823834
end
824835
end

0 commit comments

Comments
 (0)