Skip to content
This repository has been archived by the owner on Oct 5, 2023. It is now read-only.

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan Sonnek committed Nov 9, 2011
1 parent 8b9be52 commit 8ac0f9e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 16 deletions.
2 changes: 1 addition & 1 deletion lib/resque-ensure-connected.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
module Resque
module EnsureConnected
def self.verify_active_connections
ActiveRecord::Base.connection_handler.verify_active_connections!
ActiveRecord::Base.connection_handler.verify_active_connections!
end
end
end
Expand Down
1 change: 1 addition & 0 deletions test/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
require 'shoulda'
require 'mocha'
require 'resque_unit'
Resque.enable_hooks!

$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
$LOAD_PATH.unshift(File.dirname(__FILE__))
Expand Down
20 changes: 5 additions & 15 deletions test/test_resque-ensure-connected.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,40 +3,30 @@
class TestResqueEnsureConnected < Test::Unit::TestCase
class FakeJob
@queue = 'test'
def self.perform
def self.perform(foo, bar)
end
end

class FakeHandler
@invoked = false
def verify_active_connections!
@@invoked = true
puts 'invoked'
puts @@invoked
@invoked = true
end
def self.invoked?
def invoked?
@invoked
end
end

should "ensure verify connections after forking process" do
Resque.reset!
Resque.enable_hooks!
worker = Resque::Worker.new(:jobs)
Resque::Job.create(:jobs, FakeJob, 20, '/tmp')

handler = FakeHandler.new
ActiveRecord::Base.connection_handler = handler
puts FakeHandler.invoked?

Resque.run!
# Resque.reset!
# worker.work(0)
Resque.after_fork.call

puts 'assert'
puts FakeHandler.invoked?
puts handler.inspect
assert FakeHandler.invoked?
#WTF? why is this assertion failing?
assert handler.invoked?
end
end

0 comments on commit 8ac0f9e

Please sign in to comment.