Make sure the flash method is defined even if helpers are not present

This commit is contained in:
Rafael Mendonça França 2018-09-13 18:23:20 -04:00
parent 82556cd452
commit 7265b89780
No known key found for this signature in database
GPG Key ID: FC23B6D0F1EEE948
2 changed files with 11 additions and 6 deletions

@ -33,12 +33,10 @@ def add_flash_types(*types)
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
helper_method(type) if respond_to?(:helper_method)
self._flash_types += [type]
end

@ -343,11 +343,18 @@ def test_flash_factored_into_etag
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