aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/suppressor_test.rb
diff options
context:
space:
mode:
authorJahfer Husain <jahfer.husain@shopify.com>2016-05-13 10:14:51 -0400
committerJahfer Husain <jahfer.husain@shopify.com>2016-05-16 14:07:32 -0400
commit25801cfe78a124e868d7be068febf628d5fc1247 (patch)
tree00dd1ef10b4e73baa303bec2ddbda07733bd3833 /activerecord/test/cases/suppressor_test.rb
parent0991c4c6fc0c04764f34c6b65a42adce190440c3 (diff)
downloadrails-25801cfe78a124e868d7be068febf628d5fc1247.tar.gz
rails-25801cfe78a124e868d7be068febf628d5fc1247.tar.bz2
rails-25801cfe78a124e868d7be068febf628d5fc1247.zip
Keep state around for nested calls to #suppress
If a call to #suppress from the same class occurred inside another #suppress block, the suppression state would be set to false before the outer block completes. This change keeps the previous state around in memory and unwinds it as the blocks exit.
Diffstat (limited to 'activerecord/test/cases/suppressor_test.rb')
-rw-r--r--activerecord/test/cases/suppressor_test.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/activerecord/test/cases/suppressor_test.rb b/activerecord/test/cases/suppressor_test.rb
index 7d44e36419..2f00241de2 100644
--- a/activerecord/test/cases/suppressor_test.rb
+++ b/activerecord/test/cases/suppressor_test.rb
@@ -60,4 +60,16 @@ class SuppressorTest < ActiveRecord::TestCase
end
end
end
+
+ def test_suppresses_when_nested_multiple_times
+ assert_no_difference -> { Notification.count } do
+ Notification.suppress do
+ Notification.suppress { }
+ Notification.create
+ Notification.create!
+ Notification.new.save
+ Notification.new.save!
+ end
+ end
+ end
end