Skip to content

Commit 00b26e9

Browse files
committed
fix usage of Sprockets::Manifest in test
1 parent a7fc508 commit 00b26e9

File tree

1 file changed

+20
-16
lines changed

1 file changed

+20
-16
lines changed
Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,28 @@
11
require "test_helper"
22

3-
class ManifestContainerTest < ActiveSupport::TestCase
4-
def setup
5-
precompile_assets
3+
# Rails 3.x doesn't have `application.assets_manifest=`
4+
# I don't think we have to support Rails 3 + Sprockets 3 anyways!
5+
if Rails::VERSION::MAJOR > 3
6+
class ManifestContainerTest < ActiveSupport::TestCase
7+
def setup
8+
precompile_assets
69

7-
# Make a new manifest since assets weren't compiled before
8-
config = Rails.application.config
9-
path = File.join(config.paths['public'].first, config.assets.prefix)
10-
new_manifest = Sprockets::Manifest.new(Rails.application.assets, path, config.assets.manifest)
11-
Rails.application.assets_manifest = new_manifest
10+
# Make a new manifest since assets weren't compiled before
11+
config = Rails.application.config
12+
path = File.join(config.paths['public'].first, config.assets.prefix)
13+
new_manifest = Sprockets::Manifest.new(Rails.application.assets, path)
14+
Rails.application.assets_manifest = new_manifest
1215

13-
@manifest_container = React::ServerRendering::ManifestContainer.new
14-
end
16+
@manifest_container = React::ServerRendering::ManifestContainer.new
17+
end
1518

16-
def teardown
17-
clear_precompiled_assets
18-
end
19+
def teardown
20+
clear_precompiled_assets
21+
end
1922

20-
def test_find_asset_gets_asset_contents
21-
application_js_content = @manifest_container.find_asset("application.js")
22-
assert(application_js_content.length > 50000, "It's the compiled file")
23+
def test_find_asset_gets_asset_contents
24+
application_js_content = @manifest_container.find_asset("application.js")
25+
assert(application_js_content.length > 50000, "It's the compiled file")
26+
end
2327
end
2428
end

0 commit comments

Comments
 (0)