Skip to content

Commit

Permalink
Make sure find_sources behaves in the same way when the assets don't
Browse files Browse the repository at this point in the history
exists
  • Loading branch information
rafaelfranca committed Aug 31, 2017
1 parent cfae3de commit eb0af6d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
3 changes: 2 additions & 1 deletion lib/sprockets/manifest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,8 @@ def find_sources(*args)
end
else
args.each do |path|
yield File.binread(File.join(dir, assets[path]))
asset = assets[path]
yield File.binread(File.join(dir, asset)) if asset
end
end
end
Expand Down
14 changes: 13 additions & 1 deletion test/test_manifest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,13 @@ def teardown
manifest = Sprockets::Manifest.new(@env, @dir)

result = manifest.find_sources("mobile/a.js", "mobile/b.js")
assert_equal ["var A;\n", "var B;\n"], result.to_a
assert_equal ["var A;\n", "var B;\n"], result.to_a.sort

result = manifest.find_sources("not_existent.js", "also_not_existent.js")
assert_equal [], result.to_a

result = manifest.find_sources("mobile/a.js", "also_not_existent.js")
assert_equal ["var A;\n"], result.to_a
end

test "find_sources without environment" do
Expand All @@ -645,6 +651,12 @@ def teardown

result = manifest.find_sources("mobile/a.js", "mobile/b.js")
assert_equal ["var A;\n", "var B;\n"], result.to_a

result = manifest.find_sources("not_existent.js", "also_not_existent.js")
assert_equal [], result.to_a

result = manifest.find_sources("mobile/a.js", "also_not_existent.js")
assert_equal ["var A;\n"], result.to_a
end

test "compress non-binary assets" do
Expand Down

0 comments on commit eb0af6d

Please sign in to comment.