aboutsummaryrefslogtreecommitdiffstats
path: root/actionview
diff options
context:
space:
mode:
authorToshimaru <me@toshimaru.net>2016-12-09 04:55:21 +0900
committerToshimaru <me@toshimaru.net>2016-12-09 05:21:11 +0900
commitd9ff835b99ff3c7567ccde9b1379b4deeabee32f (patch)
tree93b9258440a74ddb9f0978f5b42d8850de28fdfe /actionview
parent7407d35c5417b6ef872663936a5880ede8ab711c (diff)
downloadrails-d9ff835b99ff3c7567ccde9b1379b4deeabee32f.tar.gz
rails-d9ff835b99ff3c7567ccde9b1379b4deeabee32f.tar.bz2
rails-d9ff835b99ff3c7567ccde9b1379b4deeabee32f.zip
split DELEGATION_RESERVED_METHOD_NAMES in half
Diffstat (limited to 'actionview')
-rw-r--r--actionview/lib/action_view/template.rb2
-rw-r--r--actionview/test/fixtures/test/test_template_with_block_variable.erb1
-rw-r--r--actionview/test/fixtures/test/test_template_with_delegation_reserved_keywords.erb1
-rw-r--r--actionview/test/template/compiled_templates_test.rb14
4 files changed, 12 insertions, 6 deletions
diff --git a/actionview/lib/action_view/template.rb b/actionview/lib/action_view/template.rb
index d67f37d6d1..0afdcd1def 100644
--- a/actionview/lib/action_view/template.rb
+++ b/actionview/lib/action_view/template.rb
@@ -326,7 +326,7 @@ module ActionView
def locals_code #:nodoc:
# Only locals with valid variable names get set directly. Others will
# still be available in local_assigns.
- locals = @locals.to_set - Module::DELEGATION_RESERVED_METHOD_NAMES.dup.delete("block")
+ locals = @locals - Module::RUBY_RESERVED_KEYWORDS
locals = locals.grep(/\A(?![A-Z0-9])(?:[[:alnum:]_]|[^\0-\177])+\z/)
# Double assign to suppress the dreaded 'assigned but unused variable' warning
diff --git a/actionview/test/fixtures/test/test_template_with_block_variable.erb b/actionview/test/fixtures/test/test_template_with_block_variable.erb
deleted file mode 100644
index 2ee6a2bbdc..0000000000
--- a/actionview/test/fixtures/test/test_template_with_block_variable.erb
+++ /dev/null
@@ -1 +0,0 @@
-<%= block %> \ No newline at end of file
diff --git a/actionview/test/fixtures/test/test_template_with_delegation_reserved_keywords.erb b/actionview/test/fixtures/test/test_template_with_delegation_reserved_keywords.erb
new file mode 100644
index 0000000000..edfe52e422
--- /dev/null
+++ b/actionview/test/fixtures/test/test_template_with_delegation_reserved_keywords.erb
@@ -0,0 +1 @@
+<%= _ %> <%= arg %> <%= args %> <%= block %> \ 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 a24a245442..40ac867b38 100644
--- a/actionview/test/template/compiled_templates_test.rb
+++ b/actionview/test/template/compiled_templates_test.rb
@@ -14,10 +14,6 @@ class CompiledTemplatesTest < ActiveSupport::TestCase
render(file: "test/render_file_with_ruby_keyword_locals", locals: { class: "foo" })
end
- def test_template_with_block_variable
- assert_equal "foo", render(file: "test/test_template_with_block_variable", locals: { block: "foo" })
- end
-
def test_template_with_invalid_identifier_locals
locals = {
foo: "bar",
@@ -28,6 +24,16 @@ class CompiledTemplatesTest < ActiveSupport::TestCase
assert_equal locals.inspect, render(file: "test/render_file_inspect_local_assigns", locals: locals)
end
+ def test_template_with_delegation_reserved_keywords
+ locals = {
+ _: "one",
+ arg: "two",
+ args: "three",
+ block: "four",
+ }
+ assert_equal "one two three four", render(file: "test/test_template_with_delegation_reserved_keywords", locals: locals)
+ end
+
def test_template_with_unicode_identifier
assert_equal "🎂", render(file: "test/render_file_unicode_local", locals: { 🎃: "🎂" })
end