Skip to content

Commit bc91781

Browse files
committed
Iron out problems left uncaught during rebase
1 parent 2080136 commit bc91781

File tree

4 files changed

+17
-12
lines changed

4 files changed

+17
-12
lines changed

lib/react/jsx.rb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,15 @@ module JSX
88
def self.context
99
# lazily loaded during first request and reloaded every time when in dev or test
1010
unless @context && ::Rails.env.production?
11-
12-
# TODO: create React::Source::contents_for
1311
contents =
1412
# If execjs uses therubyracer, there is no 'global'. Make sure
1513
# we have it so JSX script can work properly.
1614
'var global = global || this;' +
17-
File.read(React::Source.bundled_path_for('JSXTransformer.js'))
15+
16+
# search for transformer file using sprockets - allows user to override
17+
# this file in his own application
18+
File.read(::Rails.application.assets.resolve('JSXTransformer.js'))
19+
1820
@context = ExecJS.compile(contents)
1921
end
2022

lib/react/rails/railtie.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ class Railtie < ::Rails::Railtie
88
# run after all initializers to allow sprockets to pick up react.js and
99
# jsxtransformer.js from end-user to override ours if needed
1010
config.after_initialize do |app|
11-
variant = app.config.react.variant
12-
1311
# Mimic behavior of ember-rails...
1412
# We want to include different files in dev/prod. The unminified builds
1513
# contain console logging for invariants and logging to help catch

test/jsxtransform_test.rb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ class JSXTransformTest < ActionDispatch::IntegrationTest
2727

2828
test 'asset pipeline should transform JSX' do
2929
get 'assets/example.js'
30+
FileUtils.rm_r CACHE_PATH if CACHE_PATH.exist?
3031
assert_response :success
3132
assert_equal EXPECTED_JS, @response.body
32-
FileUtils.rm_r CACHE_PATH if CACHE_PATH.exist?
3333
end
3434

3535
test 'asset pipeline should transform JSX + Coffeescript' do
@@ -50,9 +50,11 @@ class JSXTransformTest < ActionDispatch::IntegrationTest
5050

5151
FileUtils.mv hidden_path, replacing_path
5252
get 'assets/example3.js'
53-
assert_response :success
54-
assert_equal 'test_confirmation_token_jsx_transformed;', @response.body
53+
5554
FileUtils.mv replacing_path, hidden_path
5655
FileUtils.rm_r CACHE_PATH if CACHE_PATH.exist?
56+
57+
assert_response :success
58+
assert_equal 'test_confirmation_token_jsx_transformed;', @response.body
5759
end
5860
end

test/react_test.rb

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,12 @@ class ReactTest < ActionDispatch::IntegrationTest
1111
File.open(actual_react_file_path, 'w') {|f| f.write react_file_token}
1212

1313
get 'assets/react.js'
14-
assert_response :success
15-
assert_equal react_file_token, @response.body
1614

1715
File.open(actual_react_file_path, 'w') {|f| f.write actual_react_file_content}
1816
FileUtils.rm_r CACHE_PATH if CACHE_PATH.exist?
17+
18+
assert_response :success
19+
assert_equal react_file_token, @response.body
1920
end
2021

2122
test 'asset pipeline should deliver drop-in react file replacement' do
@@ -24,10 +25,12 @@ class ReactTest < ActionDispatch::IntegrationTest
2425

2526
FileUtils.mv hidden_path, replacing_path
2627
get 'assets/react.js'
27-
assert_response :success
28-
assert_equal "'test_confirmation_token_react_content';\n", @response.body
28+
2929
FileUtils.mv replacing_path, hidden_path
3030
FileUtils.rm_r CACHE_PATH if CACHE_PATH.exist?
31+
32+
assert_response :success
33+
assert_equal "'test_confirmation_token_react_content';\n", @response.body
3134
end
3235

3336
end

0 commit comments

Comments
 (0)