File tree Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -43,7 +43,8 @@ def queue_adapter=(name_or_adapter)
43
43
assign_adapter ( name_or_adapter . to_s , queue_adapter )
44
44
else
45
45
if queue_adapter? ( name_or_adapter )
46
- adapter_name = "#{ name_or_adapter . class . name . demodulize . remove ( 'Adapter' ) . underscore } "
46
+ adapter_class = name_or_adapter . is_a? ( Module ) ? name_or_adapter : name_or_adapter . class
47
+ adapter_name = "#{ adapter_class . name . demodulize . remove ( 'Adapter' ) . underscore } "
47
48
assign_adapter ( adapter_name , name_or_adapter )
48
49
else
49
50
raise ArgumentError
Original file line number Diff line number Diff line change @@ -50,4 +50,23 @@ class QueueAdapterTest < ActiveJob::TestCase
50
50
51
51
assert_not_nil child_job_three . queue_adapter
52
52
end
53
+
54
+ test "should extract a reasonable name from a class instance" do
55
+ child_job = Class . new ( ActiveJob ::Base )
56
+ child_job . queue_adapter = ActiveJob ::QueueAdapters ::StubOneAdapter . new
57
+ assert_equal "stub_one" , child_job . queue_adapter_name
58
+ end
59
+
60
+ module StubThreeAdapter
61
+ class << self
62
+ def enqueue ( *) ; end
63
+ def enqueue_at ( *) ; end
64
+ end
65
+ end
66
+
67
+ test "should extract a reasonable name from a class or module" do
68
+ child_job = Class . new ( ActiveJob ::Base )
69
+ child_job . queue_adapter = StubThreeAdapter
70
+ assert_equal "stub_three" , child_job . queue_adapter_name
71
+ end
53
72
end
You can’t perform that action at this time.
0 commit comments