Skip to content
This repository was archived by the owner on Oct 19, 2018. It is now read-only.

Commit f747191

Browse files
catmandozetachang
authored andcommitted
closes #148
# Conflicts: # Gemfile
1 parent 5a3d69d commit f747191

File tree

4 files changed

+22
-4
lines changed

4 files changed

+22
-4
lines changed

lib/generators/reactive_ruby/test_app/templates/views/layouts/test_layout.html.erb

Whitespace-only changes.

lib/generators/reactive_ruby/test_app/test_app_generator.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ def configure_test_app
3434
"#{test_app_path}/app/views/components/hello_world.rb", force: true
3535
template 'views/components/todo.rb',
3636
"#{test_app_path}/app/views/components/todo.rb", force: true
37+
template 'views/layouts/test_layout.html.erb',
38+
"#{test_app_path}/app/views/layouts/test_layout.html.erb", force: true
39+
template 'views/layouts/test_layout.html.erb',
40+
"#{test_app_path}/app/views/layouts/explicit_layout.html.erb", force: true
3741
end
3842

3943
def clean_superfluous_files

lib/reactive-ruby/rails/controller_helper.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ module Rails
55
class ActionController::Base
66
def render_component(*args)
77
@component_name = ((args[0].is_a? Hash) || args.empty?) ? params[:action].camelize : args.shift
8-
@render_params = (args[0].is_a? Hash) ? args[0] : {}
9-
render inline: "<%= react_component @component_name, @render_params, { prerender: !params[:no_prerender] } %>", layout: 'application'
8+
@render_params = args.shift || {}
9+
options = args[0] || {}
10+
layout = options.key?(:layout) ? options[:layout].to_s : :default
11+
render inline: "<%= react_component @component_name, @render_params, { prerender: !params[:no_prerender] } %>", layout: layout
1012
end
1113
end
1214
end

spec/controller_helper_spec.rb

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,26 @@ class TestController < ActionController::Base; end
88

99
describe '#render_component' do
1010
controller do
11+
12+
layout "test_layout"
13+
1114
def index
1215
render_component
1316
end
17+
18+
def new
19+
render_component "Index", {}, layout: :explicit_layout
20+
end
1421
end
1522

16-
it 'renders the application layout' do
23+
it 'renders with the default layout' do
1724
get :index, no_prerender: true
18-
expect(response).to render_template(layout: :application)
25+
expect(response).to render_template(layout: :test_layout)
26+
end
27+
28+
it "renders with a specified layout" do
29+
get :new, no_prerender: true
30+
expect(response).to render_template(layout: :explicit_layout)
1931
end
2032
end
2133
end

0 commit comments

Comments
 (0)