From a67dc3823a129dbac14a1a2be517a5d93894fad2 Mon Sep 17 00:00:00 2001 From: "helbig@mediapeers.com" Date: Wed, 23 Mar 2011 09:37:17 +0100 Subject: [PATCH] make send_later work for module methods --- lib/delayed/performable_method.rb | 4 ++-- spec/delayed_method_spec.rb | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/lib/delayed/performable_method.rb b/lib/delayed/performable_method.rb index 18bc77ac5..8f6e8fd3b 100644 --- a/lib/delayed/performable_method.rb +++ b/lib/delayed/performable_method.rb @@ -38,7 +38,7 @@ def load(arg) def dump(arg) case arg - when Class then class_to_string(arg) + when Class, Module then class_to_string(arg) when ActiveRecord::Base then ar_to_string(arg) else arg end @@ -52,4 +52,4 @@ def class_to_string(obj) "CLASS:#{obj.name}" end end -end \ No newline at end of file +end diff --git a/spec/delayed_method_spec.rb b/spec/delayed_method_spec.rb index e3911dcdc..c2b007df1 100644 --- a/spec/delayed_method_spec.rb +++ b/spec/delayed_method_spec.rb @@ -11,6 +11,12 @@ def say_hello end end +module RandomModule + def self.say_hello + 'hello' + end +end + class ErrorObject def throw @@ -110,6 +116,14 @@ def read(story) job.payload_object.perform.should == 'Epilog: Once upon...' end + it "should store the object as string if it's a module" do + RandomModule.send_later(:say_hello) + job = Delayed::Job.find(:first) + job.payload_object.method.should == :say_hello + job.payload_object.object.should == "CLASS:RandomModule" + job.payload_object.perform.should == 'hello' + end + it "should call send later on methods which are wrapped with handle_asynchronously" do story = Story.create :text => 'Once upon...'