Skip to content

Commit 12cfb65

Browse files
committed
Merge pull request resque#735 from kares/master
[master] 1.8 compat regression
2 parents ee8d212 + a8e611f commit 12cfb65

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

lib/resque/helpers.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,15 @@ def constantize(camel_cased_word)
4848
constant.const_get(name)
4949
else
5050
candidate = constant.const_get(name)
51-
next candidate if constant.const_defined?(name, false)
51+
args = Module.method(:const_defined?).arity != 1 ? [false] : []
52+
next candidate if constant.const_defined?(name, *args)
5253
next candidate unless Object.const_defined?(name)
5354

5455
# Go down the ancestors to check it it's owned
5556
# directly before we reach Object or the end of ancestors.
5657
constant = constant.ancestors.inject do |const, ancestor|
5758
break const if ancestor == Object
58-
break ancestor if ancestor.const_defined?(name, false)
59+
break ancestor if ancestor.const_defined?(name, *args)
5960
const
6061
end
6162

test/worker_test.rb

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ def self.perform
384384
assert_equal nil, found
385385
end
386386
end
387-
387+
388388
it "cleans up dead worker info on start (crash recovery)" do
389389
# first we fake out two dead workers
390390
workerA = Resque::Worker.new(:jobs)
@@ -713,4 +713,13 @@ def self.on_failure_store_exception(exc, *args)
713713
end
714714
end
715715
end
716+
717+
it "constantizes" do
718+
assert_same Kernel, Resque::Worker.constantize(:Kernel)
719+
assert_same MiniTest::Unit::TestCase, Resque::Worker.constantize('MiniTest::Unit::TestCase')
720+
assert_raises NameError do
721+
Resque::Worker.constantize('Object::MissingConstant')
722+
end
723+
end
724+
716725
end

0 commit comments

Comments
 (0)