Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
37 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,11 @@ | ||
require 'active_job/queue_adapters/inline_queue' | ||
|
||
module ActiveJob | ||
class Base | ||
class << self | ||
def enqueue(*args) | ||
ActiveJob::QueueAdapters::InlineQueue.queue self, *args | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
module ActiveJob | ||
module QueueAdapters | ||
class InlineQueue | ||
class << self | ||
def queue(job, *args) | ||
job.perform *args | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,19 @@ | ||
require 'helper' | ||
require 'jobs/hello_job' | ||
|
||
|
||
class QueuingTest < ActiveSupport::TestCase | ||
test 'the truth' do | ||
assert true | ||
setup do | ||
$BUFFER = [] | ||
end | ||
|
||
test 'run queued job' do | ||
HelloJob.enqueue | ||
assert_equal "David says hello", $BUFFER.pop | ||
end | ||
|
||
test 'run queued job with parameters' do | ||
HelloJob.enqueue "Jamie" | ||
assert_equal "Jamie says hello", $BUFFER.pop | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class HelloJob < ActiveJob::Base | ||
def self.perform(greeter = "David") | ||
$BUFFER << "#{greeter} says hello" | ||
end | ||
end |