mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Merge pull request #33569 from eric-hemasystems/conditional-flash-helper
Conditionally use `helper_method` in Flash concern
This commit is contained in:
commit
19cb7a9887
2 changed files with 13 additions and 3 deletions
|
@ -33,10 +33,12 @@ module ActionController #:nodoc:
|
|||
types.each do |type|
|
||||
next if _flash_types.include?(type)
|
||||
|
||||
if respond_to? :helper_method
|
||||
define_method(type) do
|
||||
request.flash[type]
|
||||
end
|
||||
helper_method type
|
||||
end
|
||||
|
||||
self._flash_types += [type]
|
||||
end
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue