mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
Demo nested job spec
This commit is contained in:
10
app/jobs/regular/inner_job.rb
Normal file
10
app/jobs/regular/inner_job.rb
Normal file
@@ -0,0 +1,10 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Jobs
|
||||
class InnerJob < ::Jobs::Base
|
||||
def execute(args)
|
||||
puts "Starting inner job"
|
||||
puts "Finishing inner job"
|
||||
end
|
||||
end
|
||||
end
|
11
app/jobs/regular/outer_job.rb
Normal file
11
app/jobs/regular/outer_job.rb
Normal file
@@ -0,0 +1,11 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Jobs
|
||||
class OuterJob < ::Jobs::Base
|
||||
def execute(args)
|
||||
puts "Starting outer job"
|
||||
Jobs.enqueue(:inner_job)
|
||||
puts "Done outer job"
|
||||
end
|
||||
end
|
||||
end
|
11
spec/jobs/nested_job_spec.rb
Normal file
11
spec/jobs/nested_job_spec.rb
Normal file
@@ -0,0 +1,11 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
describe "nested jobs" do
|
||||
before { Jobs.run_immediately! }
|
||||
|
||||
it "works" do
|
||||
puts "Starting spec"
|
||||
Jobs.enqueue(:outer_job)
|
||||
puts "Done spec"
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user