diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2018-09-13 18:23:20 -0400 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2018-09-13 18:23:20 -0400 |
commit | 7265b897805aee6b858fb72f5fc33e4622635dab (patch) | |
tree | a2a166d96753731a520077d72405092bffc54543 /actionpack | |
parent | 82556cd452563abcf985ca33d1c82dfa3d4fc443 (diff) | |
download | rails-7265b897805aee6b858fb72f5fc33e4622635dab.tar.gz rails-7265b897805aee6b858fb72f5fc33e4622635dab.tar.bz2 rails-7265b897805aee6b858fb72f5fc33e4622635dab.zip |
Make sure the flash method is defined even if helpers are not present
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/lib/action_controller/metal/flash.rb | 8 | ||||
-rw-r--r-- | actionpack/test/controller/flash_test.rb | 9 |
2 files changed, 11 insertions, 6 deletions
diff --git a/actionpack/lib/action_controller/metal/flash.rb b/actionpack/lib/action_controller/metal/flash.rb index 1ecee811fb..380f2e9591 100644 --- a/actionpack/lib/action_controller/metal/flash.rb +++ b/actionpack/lib/action_controller/metal/flash.rb @@ -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 diff --git a/actionpack/test/controller/flash_test.rb b/actionpack/test/controller/flash_test.rb index a4330897cf..409a4ec2e6 100644 --- a/actionpack/test/controller/flash_test.rb +++ b/actionpack/test/controller/flash_test.rb @@ -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 |