diff options
author | José Valim <jose.valim@gmail.com> | 2010-01-13 22:59:27 +0100 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-01-14 01:07:03 +0100 |
commit | 116df09c3e4a57a6b0a57a5134c451687113ece1 (patch) | |
tree | 066f99faac94657761377003516e64e7a6f926ac /activeresource/test/cases | |
parent | 7c3573f32757e9c4c6b6140499a3e7dfe2d335b1 (diff) | |
download | rails-116df09c3e4a57a6b0a57a5134c451687113ece1.tar.gz rails-116df09c3e4a57a6b0a57a5134c451687113ece1.tar.bz2 rails-116df09c3e4a57a6b0a57a5134c451687113ece1.zip |
Add notifications to ActiveResource.
Diffstat (limited to 'activeresource/test/cases')
-rw-r--r-- | activeresource/test/cases/subscriber_test.rb | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/activeresource/test/cases/subscriber_test.rb b/activeresource/test/cases/subscriber_test.rb new file mode 100644 index 0000000000..7100b02872 --- /dev/null +++ b/activeresource/test/cases/subscriber_test.rb @@ -0,0 +1,39 @@ +require "abstract_unit" +require "fixtures/person" +require "rails/subscriber/test_helper" +require "active_resource/railties/subscriber" + +module SubscriberTest + Rails::Subscriber.add(:active_resource, ActiveResource::Railties::Subscriber.new) + + def setup + @matz = { :id => 1, :name => 'Matz' }.to_xml(:root => 'person') + ActiveResource::HttpMock.respond_to do |mock| + mock.get "/people/1.xml", {}, @matz + end + + super + end + + def set_logger(logger) + ActiveResource::Base.logger = logger + end + + def test_request_notification + matz = Person.find(1) + wait + assert_equal 2, @logger.logged(:info).size + assert_equal "GET http://somewhere.else:80/people/1.xml", @logger.logged(:info)[0] + assert_match /\-\-\> 200 200 106/, @logger.logged(:info)[1] + end + + class SyncSubscriberTest < ActiveSupport::TestCase + include Rails::Subscriber::SyncTestHelper + include SubscriberTest + end + + class AsyncSubscriberTest < ActiveSupport::TestCase + include Rails::Subscriber::AsyncTestHelper + include SubscriberTest + end +end
\ No newline at end of file |