Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix config.server_bundle_js file in generator #295

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/generators/react_on_rails/base_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ def create_react_directories
def copy_base_files
base_path = "base/base/"
%w(app/controllers/hello_world_controller.rb
config/initializers/react_on_rails.rb
client/.babelrc
client/index.jade
client/server.js
Expand All @@ -124,7 +123,8 @@ def copy_base_files

def template_base_files
base_path = "base/base/"
%w(Procfile.dev
%w(config/initializers/react_on_rails.rb
Procfile.dev
Procfile.dev-hot
app/views/hello_world/index.html.erb
client/app/bundles/HelloWorld/components/HelloWorldWidget.jsx
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@

# Server rendering:
# Server bundle is a single file for all server rendering of components.
# Set the server_bundle_js_file to "" if you know that you will not be server rendering.
<%- if options.server_rendering? %>
config.server_bundle_js_file = "app/assets/javascripts/generated/server-bundle.js"
<% else %>
config.server_bundle_js_file = ""
<%- end %>
# increase if you're on JRuby
config.server_renderer_pool_size = 1
# seconds
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,12 @@
%w(client/webpack.server.rails.config.js
client/app/bundles/HelloWorld/startup/serverRegistration.jsx).each { |file| assert_no_file(file) }
end

it "sets server bundle js file to '' in react_on_rails initializer" do
assert_file("config/initializers/react_on_rails.rb") do |contents|
assert_match(/config.server_bundle_js_file = ""/, contents)
end
end
end

shared_examples "base_generator:server_rendering" do
Expand Down Expand Up @@ -177,4 +183,11 @@
assert_match("gem 'therubyracer', platforms: :ruby", contents)
end
end

it "sets server bundle js file to server-bundle in react_on_rails initializer" do
regexp = %r{config.server_bundle_js_file = "app/assets/javascripts/generated/server-bundle.js"}
assert_file("config/initializers/react_on_rails.rb") do |contents|
assert_match(regexp, contents)
end
end
end