提交 1413ee99 编写于 作者: R Ricardo de Cillo

Custom flash should be defined only for the class that defines it and it's subclasses.

上级 defdeed2
* Fix custom flash type definition. Misusage of the `_flash_types` class variable
caused an error when reloading controllers with custom flash types.
Fixes #12057
*Ricardo de Cillo*
* Do not break params filtering on `nil` values.
Fixes #12149.
......
......@@ -37,7 +37,7 @@ def add_flash_types(*types)
end
helper_method type
_flash_types << type
self._flash_types += [type]
end
end
end
......
......@@ -214,6 +214,18 @@ def test_redirect_to_with_adding_flash_types
get :redirect_with_foo_flash
assert_equal "for great justice", @controller.send(:flash)[:foo]
end
class SubclassesTestController < TestController; end
def test_add_flash_type_to_subclasses
TestController.add_flash_types :foo
assert SubclassesTestController._flash_types.include?(:foo)
end
def test_do_not_add_flash_type_to_parent_class
SubclassesTestController.add_flash_types :bar
assert_not TestController._flash_types.include?(:bar)
end
end
class FlashIntegrationTest < ActionDispatch::IntegrationTest
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册