2010-01-13 16:59:27 -05:00
|
|
|
require "abstract_unit"
|
|
|
|
require "fixtures/person"
|
2010-02-15 09:44:30 -05:00
|
|
|
require "rails/log_subscriber/test_helper"
|
|
|
|
require "active_resource/railties/log_subscriber"
|
2010-02-08 15:30:59 -05:00
|
|
|
require "active_support/core_ext/hash/conversions"
|
2010-01-13 16:59:27 -05:00
|
|
|
|
2010-02-15 11:20:11 -05:00
|
|
|
# TODO: This test should be part of Railties
|
2010-02-15 09:44:30 -05:00
|
|
|
class LogSubscriberTest < ActiveSupport::TestCase
|
|
|
|
include Rails::LogSubscriber::TestHelper
|
|
|
|
Rails::LogSubscriber.add(:active_resource, ActiveResource::Railties::LogSubscriber.new)
|
2010-01-13 16:59:27 -05:00
|
|
|
|
|
|
|
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
|
2010-02-08 15:30:59 -05:00
|
|
|
assert_equal "GET http://37s.sunrise.i:3000/people/1.xml", @logger.logged(:info)[0]
|
2010-01-13 16:59:27 -05:00
|
|
|
assert_match /\-\-\> 200 200 106/, @logger.logged(:info)[1]
|
|
|
|
end
|
2010-02-23 20:31:17 -05:00
|
|
|
end
|