aboutsummaryrefslogtreecommitdiffstats
path: root/actionview/test
diff options
context:
space:
mode:
authorAndrew White <andrew.white@unboxed.co>2017-01-15 13:41:39 +0000
committerAndrew White <andrew.white@unboxed.co>2017-01-15 13:41:39 +0000
commitb5edc55d9fc3f6fc87ab06b5897917e051a82aef (patch)
treedb6b8adacb9552cf7b67467d4a266af5f4562d23 /actionview/test
parenteec4c2e978be15b85ba8f3efa054cb43acf1bdda (diff)
downloadrails-b5edc55d9fc3f6fc87ab06b5897917e051a82aef.tar.gz
rails-b5edc55d9fc3f6fc87ab06b5897917e051a82aef.tar.bz2
rails-b5edc55d9fc3f6fc87ab06b5897917e051a82aef.zip
Allow render locals to be assigned to instance variables
In #26672 we blocked use of Ruby keywords as identifiers for view locals but inadvertently broke the use of instance variable names as identifiers. Whilst not explicitly documented this behavior has been around for a long time and there's no need to break it now. Fixes #27480.
Diffstat (limited to 'actionview/test')
-rw-r--r--actionview/test/fixtures/test/render_file_instance_variable.erb1
-rw-r--r--actionview/test/template/compiled_templates_test.rb4
2 files changed, 5 insertions, 0 deletions
diff --git a/actionview/test/fixtures/test/render_file_instance_variable.erb b/actionview/test/fixtures/test/render_file_instance_variable.erb
new file mode 100644
index 0000000000..5344ac8a66
--- /dev/null
+++ b/actionview/test/fixtures/test/render_file_instance_variable.erb
@@ -0,0 +1 @@
+<%= @foo %> \ No newline at end of file
diff --git a/actionview/test/template/compiled_templates_test.rb b/actionview/test/template/compiled_templates_test.rb
index 40ac867b38..adb2be9be4 100644
--- a/actionview/test/template/compiled_templates_test.rb
+++ b/actionview/test/template/compiled_templates_test.rb
@@ -38,6 +38,10 @@ class CompiledTemplatesTest < ActiveSupport::TestCase
assert_equal "🎂", render(file: "test/render_file_unicode_local", locals: { 🎃: "🎂" })
end
+ def test_template_with_instance_variable_identifier
+ assert_equal "bar", render(file: "test/render_file_instance_variable", locals: { "@foo": "bar" })
+ end
+
def test_template_gets_recompiled_when_using_different_keys_in_local_assigns
assert_equal "one", render(file: "test/render_file_with_locals_and_default")
assert_equal "two", render(file: "test/render_file_with_locals_and_default", locals: { secret: "two" })