aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/test
diff options
context:
space:
mode:
authorMyron Marston <myron.marston@gmail.com>2011-04-28 08:27:15 -0700
committerMyron Marston <myron.marston@gmail.com>2011-04-28 08:27:15 -0700
commitfef22157b07f101229d29544d578bfe2cb9fedfe (patch)
tree8053e5b9495da805f4eb12c34885583346914a5e /activemodel/test
parent9a385394acd6599ff588daad491e9e07ee716091 (diff)
downloadrails-fef22157b07f101229d29544d578bfe2cb9fedfe.tar.gz
rails-fef22157b07f101229d29544d578bfe2cb9fedfe.tar.bz2
rails-fef22157b07f101229d29544d578bfe2cb9fedfe.zip
Fix bug with AM::Observer disablement.
Now that we propagate the enabling/disabling to descendants, we no longer have to check the disabled_observer Set on each superclass of the model class. This was causing a bug when disabling all observers at a superclass level and then enabling an individual observer at a subclass level. Plus the logic is simpler now :).
Diffstat (limited to 'activemodel/test')
-rw-r--r--activemodel/test/cases/observer_array_test.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/activemodel/test/cases/observer_array_test.rb b/activemodel/test/cases/observer_array_test.rb
index 38e4fd59fc..3ede5682b4 100644
--- a/activemodel/test/cases/observer_array_test.rb
+++ b/activemodel/test/cases/observer_array_test.rb
@@ -65,6 +65,16 @@ class ObserverArrayTest < ActiveModel::TestCase
assert_observer_notified Budget, AuditTrail
end
+ test "can enable observers on individual models without affecting those observers on other models" do
+ ORM.observers.disable :all
+ Budget.observers.enable AuditTrail
+
+ assert_observer_not_notified Widget, WidgetObserver
+ assert_observer_not_notified Budget, BudgetObserver
+ assert_observer_not_notified Widget, AuditTrail
+ assert_observer_notified Budget, AuditTrail
+ end
+
test "can disable observers for the duration of a block" do
yielded = false
ORM.observers.disable :budget_observer do