mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-21 09:40:13 +01:00
Changes you will need to make: * In your environment.rb, you will need to update references to a few files per environment.rb.tmpl * In your environment.rb, you will need to specify the local time zone of the computer that is running your Tracks install. Other notes on my changes: * Modified our code to take advantage of Rails 2.1's slick time zone support. * Upgraded will_paginate for compatibility * Hacked the Selenium on Rails plugin, which has not been updated in some time and does not support Rails 2.1 * Verified that all tests pass on my machine, including Selenium tests -- I'd like confirmation from others, too.
57 lines
1.3 KiB
Ruby
57 lines
1.3 KiB
Ruby
require 'abstract_unit'
|
|
require 'stringio'
|
|
|
|
class CleanLoggerTest < Test::Unit::TestCase
|
|
def setup
|
|
@out = StringIO.new
|
|
@logger = Logger.new(@out)
|
|
end
|
|
|
|
def test_format_message
|
|
@logger.error 'error'
|
|
assert_equal "error\n", @out.string
|
|
end
|
|
|
|
def test_silence
|
|
# Without yielding self.
|
|
@logger.silence do
|
|
@logger.debug 'debug'
|
|
@logger.info 'info'
|
|
@logger.warn 'warn'
|
|
@logger.error 'error'
|
|
@logger.fatal 'fatal'
|
|
end
|
|
|
|
# Yielding self.
|
|
@logger.silence do |logger|
|
|
logger.debug 'debug'
|
|
logger.info 'info'
|
|
logger.warn 'warn'
|
|
logger.error 'error'
|
|
logger.fatal 'fatal'
|
|
end
|
|
|
|
# Silencer off.
|
|
Logger.silencer = false
|
|
@logger.silence do |logger|
|
|
logger.warn 'unsilenced'
|
|
end
|
|
Logger.silencer = true
|
|
|
|
assert_equal "error\nfatal\nerror\nfatal\nunsilenced\n", @out.string
|
|
end
|
|
|
|
def test_datetime_format
|
|
@logger.formatter = Logger::Formatter.new
|
|
@logger.datetime_format = "%Y-%m-%d"
|
|
@logger.debug 'debug'
|
|
assert_equal "%Y-%m-%d", @logger.datetime_format
|
|
assert_match(/D, \[\d\d\d\d-\d\d-\d\d#\d+\] DEBUG -- : debug/, @out.string)
|
|
end
|
|
|
|
def test_nonstring_formatting
|
|
an_object = [1, 2, 3, 4, 5]
|
|
@logger.debug an_object
|
|
assert_equal("#{an_object.inspect}\n", @out.string)
|
|
end
|
|
end
|