aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorRafael França <rafaelmfranca@gmail.com>2018-09-13 16:19:45 -0400
committerGitHub <noreply@github.com>2018-09-13 16:19:45 -0400
commit19cb7a9887aa74304e01e5d3b0cb4ecfe6bd554b (patch)
treee36b390ab7402e675169185f53d1280f7ac9db94 /actionpack
parentb20762e56c0412aee02bd244a3128c933c484e52 (diff)
parent34326af1d44be1c17fb8208578b25d7162a118fe (diff)
downloadrails-19cb7a9887aa74304e01e5d3b0cb4ecfe6bd554b.tar.gz
rails-19cb7a9887aa74304e01e5d3b0cb4ecfe6bd554b.tar.bz2
rails-19cb7a9887aa74304e01e5d3b0cb4ecfe6bd554b.zip
Merge pull request #33569 from eric-hemasystems/conditional-flash-helper
Conditionally use `helper_method` in Flash concern
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/lib/action_controller/metal/flash.rb8
-rw-r--r--actionpack/test/controller/flash_test.rb8
2 files changed, 13 insertions, 3 deletions
diff --git a/actionpack/lib/action_controller/metal/flash.rb b/actionpack/lib/action_controller/metal/flash.rb
index 5115c2fadf..1ecee811fb 100644
--- a/actionpack/lib/action_controller/metal/flash.rb
+++ b/actionpack/lib/action_controller/metal/flash.rb
@@ -33,10 +33,12 @@ module ActionController #:nodoc:
types.each do |type|
next if _flash_types.include?(type)
- define_method(type) do
- request.flash[type]
+ if respond_to? :helper_method
+ define_method(type) do
+ request.flash[type]
+ end
+ helper_method type
end
- helper_method type
self._flash_types += [type]
end
diff --git a/actionpack/test/controller/flash_test.rb b/actionpack/test/controller/flash_test.rb
index 34bc2c0caa..a4330897cf 100644
--- a/actionpack/test/controller/flash_test.rb
+++ b/actionpack/test/controller/flash_test.rb
@@ -342,6 +342,14 @@ class FlashIntegrationTest < ActionDispatch::IntegrationTest
end
end
+ def test_flash_usable_in_metal_without_helper
+ assert_nothing_raised do
+ Class.new ActionController::Metal do
+ include ActionController::Flash
+ end
+ end
+ end
+
private
# Overwrite get to send SessionSecret in env hash