Skip to content

Commit 69d5d40

Browse files
Aaron Peckham & Michael Sofaerdefunkt
authored andcommitted
very_verbose works in the afternoon
1 parent 22970a2 commit 69d5d40

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

lib/resque/worker.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ def log(message)
489489
if verbose
490490
puts "*** #{message}"
491491
elsif very_verbose
492-
time = Time.now.strftime('%I:%M:%S %Y-%m-%d')
492+
time = Time.now.strftime('%H:%M:%S %Y-%m-%d')
493493
puts "** [#{time}] #$$: #{message}"
494494
end
495495
end

test/test_helper.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,3 +130,16 @@ def with_failure_backend(failure_backend, &block)
130130
ensure
131131
Resque::Failure.backend = previous_backend
132132
end
133+
134+
class Time
135+
# Thanks, Timecop
136+
class << self
137+
alias_method :now_without_mock_time, :now
138+
139+
def now_with_mock_time
140+
$fake_time || now_without_mock_time
141+
end
142+
143+
alias_method :now, :now_with_mock_time
144+
end
145+
end

test/worker_test.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,19 @@
301301
assert $BEFORE_FORK_CALLED
302302
end
303303

304+
test "very verbose works in the afternoon" do
305+
require 'time'
306+
$last_puts = ""
307+
$fake_time = Time.parse("15:44:33 2011-03-02")
308+
singleton = class << @worker; self end
309+
singleton.send :define_method, :puts, lambda { |thing| $last_puts = thing }
310+
311+
@worker.very_verbose = true
312+
@worker.log("some log text")
313+
314+
assert_match /\*\* \[15:44:33 2011-03-02\] \d+: some log text/, $last_puts
315+
end
316+
304317
test "Will call an after_fork hook after forking" do
305318
Resque.redis.flushall
306319
$AFTER_FORK_CALLED = false

0 commit comments

Comments
 (0)