Commit 05cda021 by Benjamin ter Kuile Committed by Prem Sichanugrist

Fix an error when no logger was specified

* Add failing test for case when no logger is specified
* add fix for failing test
* fix teardown of no logger test
parent f1875520
...@@ -7,7 +7,7 @@ module Paperclip ...@@ -7,7 +7,7 @@ module Paperclip
end end
def logger #:nodoc: def logger #:nodoc:
@logger ||= options[:logger] || Logger.new(STDOUT) @logger ||= options[:logger] || ::Logger.new(STDOUT)
end end
def logger=(logger) def logger=(logger)
......
...@@ -33,6 +33,21 @@ class PaperclipTest < Test::Unit::TestCase ...@@ -33,6 +33,21 @@ class PaperclipTest < Test::Unit::TestCase
end end
end end
context "Calling Paperclip.log without options[:logger] set" do
setup do
Paperclip.logger = nil
Paperclip.options[:logger] = nil
end
teardown do
Paperclip.options[:logger] = ActiveRecord::Base.logger
Paperclip.logger = ActiveRecord::Base.logger
end
should "not raise an error when log is called" do
assert_nothing_raised do
Paperclip.log('something')
end
end
end
context "Calling Paperclip.run with a logger" do context "Calling Paperclip.run with a logger" do
should "pass the defined logger if :log_command is set" do should "pass the defined logger if :log_command is set" do
Paperclip.options[:log_command] = true Paperclip.options[:log_command] = true
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment