Skip to content

Commit d8c3381

Browse files
committed
Update tests and README.md to reflect discussion w/ Sprockets team (sstephenson/sprockets#560) that manifest filename must be explicitly specified by user.
1 parent 8689007 commit d8c3381

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ Defaults to `/assets`. Changes the directory to compile assets to.
8585

8686
**`config.assets.manifest`**
8787

88-
Defines the full path to be used for the asset precompiler's manifest file. Defaults to using the `config.assets.prefix` directory within the public folder.
88+
Defines the full path to be used for the asset precompiler's manifest file. Must include filename. Defaults to using the `config.assets.prefix` directory within the public folder.
8989

9090
**`config.assets.digest`**
9191

@@ -134,6 +134,7 @@ The following plugins provide some extras for the Sprockets Asset Pipeline.
134134
* Unmanaged asset paths and urls fallback to linking to public/. This should make it easier to work with both compiled assets and simple static assets. As a side effect, there will never be any "asset not precompiled errors" when linking to missing assets. They will just link to a public file which may or may not exist.
135135
* JS and CSS compressors must be explicitly set. Magic detection has been removed to avoid loading compressors in environments where you want to avoid loading any of the asset libraries. Assign `config.assets.js_compressor = :uglify` or `config.assets.css_compressor = :sass` for the standard compressors.
136136
* The manifest file is now in a JSON format. Since it lives in public/ by default, the initial filename is also randomized to obfuscate public access to the resource.
137+
* `config.assets.manifest` (if used) must now include the manifest filename, e.g. `Rails.root.join('config/manifest.json')`. It cannot be a directory.
137138
* Two cleanup tasks. `rake assets:clean` is now a safe cleanup that only removes older assets that are no longer used. While `rake assets:clobber` nukes the entire `public/assets` directory and clears your filesystem cache. The clean task allows for rolling deploys that may still be linking to an old asset while the new assets are being built.
138139

139140

test/test_railtie.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,11 +180,11 @@ def test_sprockets_context_helper
180180

181181
def test_manifest_path
182182
app.configure do
183-
config.assets.manifest = Rails.root.join('config','foo')
183+
config.assets.manifest = Rails.root.join('config','foo','bar.json')
184184
end
185185
app.initialize!
186186

187-
assert_match %r{config/foo/manifest-.*\.json$}, ActionView::Base.assets_manifest.path
187+
assert_match %r{config/foo/bar\.json$}, ActionView::Base.assets_manifest.path
188188
assert_match %r{public/assets$}, ActionView::Base.assets_manifest.dir
189189
end
190190

test/test_task.rb

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ def setup
1818

1919
@dir = File.join(Dir::tmpdir, 'rails', 'task')
2020

21-
@manifest_dir = File.join(Dir::tmpdir, 'rails', 'manifest')
22-
@manifest = Sprockets::Manifest.new(@assets, @dir, @manifest_dir)
21+
@manifest_file = File.join(Dir::tmpdir, 'rails', 'manifest', 'custom-manifest.json')
22+
@manifest = Sprockets::Manifest.new(@assets, @dir, @manifest_file)
2323

2424
@environment_ran = false
2525
# Stub Rails environment task
@@ -41,8 +41,9 @@ def teardown
4141
FileUtils.rm_rf(@dir)
4242
assert Dir["#{@dir}/*"].empty?
4343

44-
FileUtils.rm_rf(@manifest_dir)
45-
assert Dir["#{@manifest_dir}/*"].empty?
44+
manifest_dir = File.dirname(@manifest_file)
45+
FileUtils.rm_rf(manifest_dir)
46+
assert Dir["#{manifest_dir}/*"].empty?
4647
end
4748

4849
def test_precompile
@@ -54,7 +55,7 @@ def test_precompile
5455
@rake['assets:precompile'].invoke
5556

5657
assert @environment_ran
57-
assert Dir["#{@manifest_dir}/manifest-*.json"].first
58+
assert File.exist?(@manifest_file)
5859
assert File.exist?("#{@dir}/#{digest_path}")
5960
end
6061

0 commit comments

Comments
 (0)