diff options
author | Yves Senn <yves.senn@gmail.com> | 2014-04-06 22:56:50 +0200 |
---|---|---|
committer | Yves Senn <yves.senn@gmail.com> | 2014-04-06 22:56:50 +0200 |
commit | 5ac58be34580345b7464287ea422c14642b5fd20 (patch) | |
tree | ac14c768e4fedc5c3681823e599f3bad63e43092 /actionpack | |
parent | baa9b9bf5372470669ef1a7b05807b8d17068af8 (diff) | |
parent | 8bbaa94c8125cf3efc0ec05cee5bf3193fbf5cf7 (diff) | |
download | rails-5ac58be34580345b7464287ea422c14642b5fd20.tar.gz rails-5ac58be34580345b7464287ea422c14642b5fd20.tar.bz2 rails-5ac58be34580345b7464287ea422c14642b5fd20.zip |
Merge pull request #14614 from tgxworld/fix_add_flash_types_test
Fix setup of adding _flash_types test.
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/test/controller/flash_test.rb | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/actionpack/test/controller/flash_test.rb b/actionpack/test/controller/flash_test.rb index 25a4857eba..ff5587d768 100644 --- a/actionpack/test/controller/flash_test.rb +++ b/actionpack/test/controller/flash_test.rb @@ -210,20 +210,29 @@ class FlashTest < ActionController::TestCase end def test_redirect_to_with_adding_flash_types - @controller.class.add_flash_types :foo + original_controller = @controller + test_controller_with_flash_type_foo = Class.new(TestController) do + add_flash_types :foo + end + @controller = test_controller_with_flash_type_foo.new get :redirect_with_foo_flash assert_equal "for great justice", @controller.send(:flash)[:foo] + ensure + @controller = original_controller end - class SubclassesTestController < TestController; end - def test_add_flash_type_to_subclasses - TestController.add_flash_types :foo - assert SubclassesTestController._flash_types.include?(:foo) + test_controller_with_flash_type_foo = Class.new(TestController) do + add_flash_types :foo + end + subclass_controller_with_no_flash_type = Class.new(test_controller_with_flash_type_foo) + assert subclass_controller_with_no_flash_type._flash_types.include?(:foo) end def test_do_not_add_flash_type_to_parent_class - SubclassesTestController.add_flash_types :bar + subclass_controller_with_flash_type_bar = Class.new(TestController) do + add_flash_types :bar + end assert_not TestController._flash_types.include?(:bar) end end |