mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Exclude added flash types from action_methods
This commit is contained in:
parent
ac87404bf8
commit
39ab10164b
3 changed files with 24 additions and 0 deletions
|
@ -1,3 +1,16 @@
|
|||
* Exclude additional flash types from `ActionController::Base.action_methods`.
|
||||
|
||||
Ensures that additional flash types defined on ActionController::Base subclasses
|
||||
are not listed as actions on that controller.
|
||||
|
||||
class MyController < ApplicationController
|
||||
add_flash_types :hype
|
||||
end
|
||||
|
||||
MyController.action_methods.include?('hype') # => false
|
||||
|
||||
*Gavin Morrice*
|
||||
|
||||
* Deleting an item from the Middleware stack will raise if the item is not found
|
||||
|
||||
Previously, calling `config.middleware.delete(ItemNotInMiddleware)` would fail silently.
|
||||
|
|
|
@ -41,6 +41,10 @@ module ActionController #:nodoc:
|
|||
self._flash_types += [type]
|
||||
end
|
||||
end
|
||||
|
||||
def action_methods #:nodoc:
|
||||
@action_methods ||= super - _flash_types.map(&:to_s).to_set
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -224,6 +224,13 @@ class FlashTest < ActionController::TestCase
|
|||
@controller = original_controller
|
||||
end
|
||||
|
||||
def test_additional_flash_types_are_not_listed_in_actions_set
|
||||
test_controller_with_flash_type_foo = Class.new(TestController) do
|
||||
add_flash_types :foo
|
||||
end
|
||||
assert_not_includes test_controller_with_flash_type_foo.action_methods, "foo"
|
||||
end
|
||||
|
||||
def test_add_flash_type_to_subclasses
|
||||
test_controller_with_flash_type_foo = Class.new(TestController) do
|
||||
add_flash_types :foo
|
||||
|
|
Loading…
Reference in a new issue