aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2013-09-13 06:24:07 -0700
committerRafael Mendonça França <rafaelmfranca@gmail.com>2013-09-13 06:24:07 -0700
commitca50043a7ad95825b3830d97294b14b665a7d698 (patch)
tree2e663f4cd2ff552bf5202996a770f2b09efcfe46 /actionpack
parent0729cc8ef840cf54dc424e6e3c2b50e8a23e22ed (diff)
parent1413ee991ccfc76b24f29eb03c9cff82e588e5d7 (diff)
downloadrails-ca50043a7ad95825b3830d97294b14b665a7d698.tar.gz
rails-ca50043a7ad95825b3830d97294b14b665a7d698.tar.bz2
rails-ca50043a7ad95825b3830d97294b14b665a7d698.zip
Merge pull request #12222 from rcillo/fix-custom-flash
Custom flash should be defined only for the class that defines it and it's subclasses Fixes #12057
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/CHANGELOG.md7
-rw-r--r--actionpack/lib/action_controller/metal/flash.rb2
-rw-r--r--actionpack/test/controller/flash_test.rb12
3 files changed, 20 insertions, 1 deletions
diff --git a/actionpack/CHANGELOG.md b/actionpack/CHANGELOG.md
index ecbdfd51ed..01e816e87c 100644
--- a/actionpack/CHANGELOG.md
+++ b/actionpack/CHANGELOG.md
@@ -1,3 +1,10 @@
+* 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.
diff --git a/actionpack/lib/action_controller/metal/flash.rb b/actionpack/lib/action_controller/metal/flash.rb
index 1d77e331f8..65351284b9 100644
--- a/actionpack/lib/action_controller/metal/flash.rb
+++ b/actionpack/lib/action_controller/metal/flash.rb
@@ -37,7 +37,7 @@ module ActionController #:nodoc:
end
helper_method type
- _flash_types << type
+ self._flash_types += [type]
end
end
end
diff --git a/actionpack/test/controller/flash_test.rb b/actionpack/test/controller/flash_test.rb
index 3b874a739a..c64ffef654 100644
--- a/actionpack/test/controller/flash_test.rb
+++ b/actionpack/test/controller/flash_test.rb
@@ -214,6 +214,18 @@ class FlashTest < ActionController::TestCase
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