Skip to content

Commit 28e976b

Browse files
Update JavascriptPackageTest for Active Storage
Prior to this commit, if `app/javascript/activestorage/index.js` contained a syntax error, `JavascriptPackageTest` would still pass because `system "yarn build"` would simply return `false` and the compiled output would not change. This commit adds `exception: true` to the `system` call so that an error will be raised if `yarn build` fails. Also, since 6c96e1c, Active Storage compiles an additional `app/assets/javascripts/activestorage.esm.js` file. This commit adds an assertion for that file as well.
1 parent 8e213f7 commit 28e976b

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

activestorage/test/javascript_package_test.rb

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,15 @@
44

55
class JavascriptPackageTest < ActiveSupport::TestCase
66
def test_compiled_code_is_in_sync_with_source_code
7-
compiled_file = File.expand_path("../app/assets/javascripts/activestorage.js", __dir__)
7+
compiled_files = %w[
8+
app/assets/javascripts/activestorage.js
9+
app/assets/javascripts/activestorage.esm.js
10+
].map do |file|
11+
Pathname(file).expand_path("#{__dir__}/..")
12+
end
813

9-
assert_no_changes -> { File.read(compiled_file) } do
10-
system "yarn build"
14+
assert_no_changes -> { compiled_files.map(&:read) } do
15+
system "yarn build", exception: true
1116
end
1217
end
1318
end

0 commit comments

Comments
 (0)