diff options
author | Rafael França <rafaelmfranca@gmail.com> | 2017-08-15 17:23:42 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-15 17:23:42 -0400 |
commit | c171890a42a641c6d8a1ef32be13e683d5c3e495 (patch) | |
tree | da5e9e18c2795195e9c61c95e42ddbf911d8901b /activesupport/test/lazy_load_hooks_test.rb | |
parent | 692fab26b142c724f0b824db5029c70a88676808 (diff) | |
parent | 7fade3dcbcfc1f5ba6c455c04f04040f077e0d70 (diff) | |
download | rails-c171890a42a641c6d8a1ef32be13e683d5c3e495.tar.gz rails-c171890a42a641c6d8a1ef32be13e683d5c3e495.tar.bz2 rails-c171890a42a641c6d8a1ef32be13e683d5c3e495.zip |
Merge pull request #30045 from albertoalmagro/fix-raise-unpermitted-parameters-regression
Load Parameters configurations on :action_controller only once
Diffstat (limited to 'activesupport/test/lazy_load_hooks_test.rb')
-rw-r--r-- | activesupport/test/lazy_load_hooks_test.rb | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/activesupport/test/lazy_load_hooks_test.rb b/activesupport/test/lazy_load_hooks_test.rb index 9c9264e8fc..c161005100 100644 --- a/activesupport/test/lazy_load_hooks_test.rb +++ b/activesupport/test/lazy_load_hooks_test.rb @@ -20,6 +20,18 @@ class LazyLoadHooksTest < ActiveSupport::TestCase assert_equal 7, i end + def test_basic_hook_with_two_registrations_only_once + i = 0 + ActiveSupport.on_load(:basic_hook_with_two_once, run_once: true) do + i += incr + end + assert_equal 0, i + ActiveSupport.run_load_hooks(:basic_hook_with_two_once, FakeContext.new(2)) + assert_equal 2, i + ActiveSupport.run_load_hooks(:basic_hook_with_two_once, FakeContext.new(5)) + assert_equal 2, i + end + def test_hook_registered_after_run i = 0 ActiveSupport.run_load_hooks(:registered_after) @@ -37,6 +49,15 @@ class LazyLoadHooksTest < ActiveSupport::TestCase assert_equal 7, i end + def test_hook_registered_after_run_with_two_registrations_only_once + i = 0 + ActiveSupport.run_load_hooks(:registered_after_with_two_once, FakeContext.new(2)) + ActiveSupport.run_load_hooks(:registered_after_with_two_once, FakeContext.new(5)) + assert_equal 0, i + ActiveSupport.on_load(:registered_after_with_two_once, run_once: true) { i += incr } + assert_equal 2, i + end + def test_hook_registered_interleaved_run_with_two_registrations i = 0 ActiveSupport.run_load_hooks(:registered_interleaved_with_two, FakeContext.new(2)) @@ -47,6 +68,22 @@ class LazyLoadHooksTest < ActiveSupport::TestCase assert_equal 7, i end + def test_hook_registered_interleaved_run_with_two_registrations_once + i = 0 + ActiveSupport + .run_load_hooks(:registered_interleaved_with_two_once, FakeContext.new(2)) + assert_equal 0, i + + ActiveSupport.on_load(:registered_interleaved_with_two_once, run_once: true) do + i += incr + end + assert_equal 2, i + + ActiveSupport + .run_load_hooks(:registered_interleaved_with_two_once, FakeContext.new(5)) + assert_equal 2, i + end + def test_hook_receives_a_context i = 0 ActiveSupport.on_load(:contextual) { i += incr } |