From 07fe3569e6240452ee9952ee7c926934fdf7f116 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Tue, 17 May 2016 09:50:35 -0700 Subject: locals can be accessed from templates rendered in the controller --- actionview/test/actionpack/abstract/layouts_test.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'actionview/test/actionpack/abstract') diff --git a/actionview/test/actionpack/abstract/layouts_test.rb b/actionview/test/actionpack/abstract/layouts_test.rb index 80bc665b0a..8c80a2d2cf 100644 --- a/actionview/test/actionpack/abstract/layouts_test.rb +++ b/actionview/test/actionpack/abstract/layouts_test.rb @@ -12,7 +12,9 @@ module AbstractControllerTests abstract! self.view_paths = [ActionView::FixtureResolver.new( + "some/template.erb" => "hello <%= foo %> bar", "layouts/hello.erb" => "With String <%= yield %>", + "layouts/hello_locals.erb" => "With String <%= yield %>", "layouts/hello_override.erb" => "With Override <%= yield %>", "layouts/overwrite.erb" => "Overwrite <%= yield %>", "layouts/with_false_layout.erb" => "False Layout <%= yield %>", @@ -32,6 +34,14 @@ module AbstractControllerTests end end + class WithStringLocals < Base + layout "hello_locals" + + def index + render :template => 'some/template', locals: { foo: "less than 3" } + end + end + class WithString < Base layout "hello" @@ -208,6 +218,12 @@ module AbstractControllerTests assert_equal "Hello blank!", controller.response_body end + test "with locals" do + controller = WithStringLocals.new + controller.process(:index) + assert_equal "With String hello less than 3 bar", controller.response_body + end + test "when layout is specified as a string, render with that layout" do controller = WithString.new controller.process(:index) -- cgit v1.2.3