Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add additional tests for AM::ObserverArray that I had missed yesterday.

  • Loading branch information...
commit 7db7aa505375db75c2205f35df743becc7647c95 1 parent fef2215
@myronmarston myronmarston authored
Showing with 50 additions and 1 deletion.
  1. +50 −1 activemodel/test/cases/observer_array_test.rb
View
51 activemodel/test/cases/observer_array_test.rb
@@ -38,6 +38,16 @@ def assert_observer_not_notified(model_class, observer_class)
assert_observer_notified Budget, AuditTrail
end
+ test "can enable individual observers using a class constant" do
+ ORM.observers.disable :all
+ ORM.observers.enable AuditTrail
+
+ assert_observer_not_notified Widget, WidgetObserver
+ assert_observer_not_notified Budget, BudgetObserver
+ assert_observer_notified Widget, AuditTrail
+ assert_observer_notified Budget, AuditTrail
+ end
+
test "can disable individual observers using a symbol" do
ORM.observers.disable :budget_observer
@@ -47,6 +57,35 @@ def assert_observer_not_notified(model_class, observer_class)
assert_observer_notified Budget, AuditTrail
end
+ test "can enable individual observers using a symbol" do
+ ORM.observers.disable :all
+ ORM.observers.enable :audit_trail
+
+ assert_observer_not_notified Widget, WidgetObserver
+ assert_observer_not_notified Budget, BudgetObserver
+ assert_observer_notified Widget, AuditTrail
+ assert_observer_notified Budget, AuditTrail
+ end
+
+ test "can disable multiple observers at a time" do
+ ORM.observers.disable :widget_observer, :budget_observer
+
+ assert_observer_not_notified Widget, WidgetObserver
+ assert_observer_not_notified Budget, BudgetObserver
+ assert_observer_notified Widget, AuditTrail
+ assert_observer_notified Budget, AuditTrail
+ end
+
+ test "can enable multiple observers at a time" do
+ ORM.observers.disable :all
+ ORM.observers.enable :widget_observer, :budget_observer
+
+ assert_observer_notified Widget, WidgetObserver
+ assert_observer_notified Budget, BudgetObserver
+ assert_observer_not_notified Widget, AuditTrail
+ assert_observer_not_notified Budget, AuditTrail
+ end
+
test "can disable all observers using :all" do
ORM.observers.disable :all
@@ -56,7 +95,17 @@ def assert_observer_not_notified(model_class, observer_class)
assert_observer_not_notified Budget, AuditTrail
end
- test "can disable observers on individual models without affecting observers on other models" do
+ test "can enable all observers using :all" do
+ ORM.observers.disable :all
+ ORM.observers.enable :all
+
+ assert_observer_notified Widget, WidgetObserver
+ assert_observer_notified Budget, BudgetObserver
+ assert_observer_notified Widget, AuditTrail
+ assert_observer_notified Budget, AuditTrail
+ end
+
+ test "can disable observers on individual models without affecting those observers on other models" do
Widget.observers.disable :all
assert_observer_not_notified Widget, WidgetObserver
Please sign in to comment.
Something went wrong with that request. Please try again.