aboutsummaryrefslogtreecommitdiffstats
path: root/actionview/test/template
diff options
context:
space:
mode:
authorMatthew Draper <matthew@trebex.net>2016-10-02 21:10:26 +1030
committerGitHub <noreply@github.com>2016-10-02 21:10:26 +1030
commit7b63f56ce0c708f05db31de04b8cd2dc6e4ef96b (patch)
tree838e720c59e900a67064d13ee70af34a76b8d162 /actionview/test/template
parent832b02620b1331212a53186023688c8e84a4ca03 (diff)
parentf9960f2d74b510e0d994d49377cec36301f7e7f0 (diff)
downloadrails-7b63f56ce0c708f05db31de04b8cd2dc6e4ef96b.tar.gz
rails-7b63f56ce0c708f05db31de04b8cd2dc6e4ef96b.tar.bz2
rails-7b63f56ce0c708f05db31de04b8cd2dc6e4ef96b.zip
Merge pull request #26672 from schpet/support_ruby_keywords_as_template_locals
Avoid compiling ruby keywords into template locals
Diffstat (limited to 'actionview/test/template')
-rw-r--r--actionview/test/template/compiled_templates_test.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/actionview/test/template/compiled_templates_test.rb b/actionview/test/template/compiled_templates_test.rb
index 7e3e5883b4..3ecac46d34 100644
--- a/actionview/test/template/compiled_templates_test.rb
+++ b/actionview/test/template/compiled_templates_test.rb
@@ -9,6 +9,25 @@ class CompiledTemplatesTest < ActiveSupport::TestCase
assert_equal "This is nil: \n", render(template: "test/nil_return")
end
+ def test_template_with_ruby_keyword_locals
+ assert_equal "The class is foo",
+ render(file: "test/render_file_with_ruby_keyword_locals", locals: { class: "foo" })
+ end
+
+ def test_template_with_invalid_identifier_locals
+ locals = {
+ foo: "bar",
+ Foo: "bar",
+ "d-a-s-h-e-s": "",
+ "white space": "",
+ }
+ assert_equal locals.inspect, render(file: "test/render_file_inspect_local_assigns", locals: locals)
+ end
+
+ def test_template_with_unicode_identifier
+ assert_equal "🎂", render(file: "test/render_file_unicode_local", locals: { 🎃: "🎂" })
+ 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" })