diff options
Diffstat (limited to 'activeresource/test')
-rw-r--r-- | activeresource/test/abstract_unit.rb | 2 | ||||
-rw-r--r-- | activeresource/test/cases/subscriber_test.rb | 39 |
2 files changed, 39 insertions, 2 deletions
diff --git a/activeresource/test/abstract_unit.rb b/activeresource/test/abstract_unit.rb index 5fa6d3023b..1e71d5d0dd 100644 --- a/activeresource/test/abstract_unit.rb +++ b/activeresource/test/abstract_unit.rb @@ -10,8 +10,6 @@ require 'rubygems' require 'test/unit' require 'active_resource' require 'active_support' -require 'active_support/test_case' -require 'active_model/test_case' $:.unshift "#{File.dirname(__FILE__)}/../test" require 'setter_trap' 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 |