diff options
author | José Valim <jose.valim@gmail.com> | 2011-08-13 08:40:13 -0700 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2011-08-13 08:40:13 -0700 |
commit | 291072a64a2b191816f395b25aae4a50d2dcfe16 (patch) | |
tree | 9f4f4a80ce6058a5c298fd79ae8cde96fd45b967 /activemodel/test | |
parent | 34689c40a03c9921b5c43ac1e120a9885edded73 (diff) | |
parent | d3c15a1d31d77e44b142c96cb55b654f3552a89d (diff) | |
download | rails-291072a64a2b191816f395b25aae4a50d2dcfe16.tar.gz rails-291072a64a2b191816f395b25aae4a50d2dcfe16.tar.bz2 rails-291072a64a2b191816f395b25aae4a50d2dcfe16.zip |
Merge pull request #2514 from myronmarston/fix_active_record_observer_disabling
Allow ActiveRecord observers to be disabled.
Diffstat (limited to 'activemodel/test')
-rw-r--r-- | activemodel/test/cases/observing_test.rb | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/activemodel/test/cases/observing_test.rb b/activemodel/test/cases/observing_test.rb index 99b1f407ae..f6ec24ae57 100644 --- a/activemodel/test/cases/observing_test.rb +++ b/activemodel/test/cases/observing_test.rb @@ -17,6 +17,10 @@ class FooObserver < ActiveModel::Observer def on_spec(record) stub.event_with(record) if stub end + + def around_save(record) + yield :in_around_save + end end class Foo @@ -133,4 +137,12 @@ class ObserverTest < ActiveModel::TestCase foo = Foo.new Foo.send(:notify_observers, :whatever, foo) end + + test "update passes a block on to the observer" do + yielded_value = nil + FooObserver.instance.update(:around_save, Foo.new) do |val| + yielded_value = val + end + assert_equal :in_around_save, yielded_value + end end |