Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Remove obsolete use case that was broken in AR::Observers

  • Loading branch information...
commit 79b08616244b31b7e63a46d9a6492bc7e67c2813 1 parent a307fd6
Evan Phoenix authored
Showing with 0 additions and 40 deletions.
  1. +0 −40 activerecord/test/cases/lifecycle_test.rb
40 activerecord/test/cases/lifecycle_test.rb
View
@@ -6,25 +6,6 @@
class SpecialDeveloper < Developer; end
-class TopicManualObserver
- include Singleton
-
- attr_reader :action, :object, :callbacks
-
- def initialize
- Topic.add_observer(self)
- @callbacks = []
- end
-
- def update(callback_method, object)
- @callbacks << { "callback_method" => callback_method, "object" => object }
- end
-
- def has_been_notified?
- !@callbacks.empty?
- end
-end
-
class TopicaAuditor < ActiveRecord::Observer
observe :topic
@@ -85,27 +66,6 @@ def test_before_destroy
assert_equal original_count - (1 + topic_to_be_destroyed.replies.size), Topic.count
end
- def test_after_save
- ActiveRecord::Base.observers = :topic_manual_observer
- ActiveRecord::Base.instantiate_observers
-
- topic = Topic.find(1)
- topic.title = "hello"
- topic.save
-
- assert TopicManualObserver.instance.has_been_notified?
- assert_equal :after_save, TopicManualObserver.instance.callbacks.last["callback_method"]
- end
-
- def test_observer_update_on_save
- ActiveRecord::Base.observers = TopicManualObserver
- ActiveRecord::Base.instantiate_observers
-
- topic = Topic.find(1)
- assert TopicManualObserver.instance.has_been_notified?
- assert_equal :after_find, TopicManualObserver.instance.callbacks.first["callback_method"]
- end
-
def test_auto_observer
topic_observer = TopicaAuditor.instance
assert_nil TopicaAuditor.observed_class
Please sign in to comment.
Something went wrong with that request. Please try again.