1
0
Fork 0
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:
Rafael França 2018-09-13 16:19:45 -04:00 committed by GitHub
commit 19cb7a9887
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 3 deletions

View file

@ -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

View file

@ -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