aboutsummaryrefslogtreecommitdiffstats
path: root/actionview/test/actionpack/abstract
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2016-05-17 09:50:35 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2016-05-17 09:50:51 -0700
commit07fe3569e6240452ee9952ee7c926934fdf7f116 (patch)
tree0493f439b4ec52014ca46eb6c613622522226c11 /actionview/test/actionpack/abstract
parentc756372b3b94796eab06b855d2c5825674138831 (diff)
downloadrails-07fe3569e6240452ee9952ee7c926934fdf7f116.tar.gz
rails-07fe3569e6240452ee9952ee7c926934fdf7f116.tar.bz2
rails-07fe3569e6240452ee9952ee7c926934fdf7f116.zip
locals can be accessed from templates rendered in the controller
Diffstat (limited to 'actionview/test/actionpack/abstract')
-rw-r--r--actionview/test/actionpack/abstract/layouts_test.rb16
1 files changed, 16 insertions, 0 deletions
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)