mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Make sure the flash method is defined even if helpers are not present
This commit is contained in:
parent
82556cd452
commit
7265b89780
2 changed files with 11 additions and 6 deletions
|
@ -33,12 +33,10 @@ 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
|
||||
define_method(type) do
|
||||
request.flash[type]
|
||||
end
|
||||
helper_method(type) if respond_to?(:helper_method)
|
||||
|
||||
self._flash_types += [type]
|
||||
end
|
||||
|
|
|
@ -343,11 +343,18 @@ class FlashIntegrationTest < ActionDispatch::IntegrationTest
|
|||
end
|
||||
|
||||
def test_flash_usable_in_metal_without_helper
|
||||
controller_class = nil
|
||||
|
||||
assert_nothing_raised do
|
||||
Class.new ActionController::Metal do
|
||||
controller_class = Class.new(ActionController::Metal) do
|
||||
include ActionController::Flash
|
||||
end
|
||||
end
|
||||
|
||||
controller = controller_class.new
|
||||
|
||||
assert_respond_to controller, :alert
|
||||
assert_respond_to controller, :notice
|
||||
end
|
||||
|
||||
private
|
||||
|
|
Loading…
Reference in a new issue