Files
openfoodnetwork/spec/services/job_processor_spec.rb
Maikel Linke 075b8d2585 Add Rails standard ApplicationJob for consistency
New Rails apps come with this class already, the job generator creates
it for every new job and Rubocop requires it as well. Let's make our
lives easier and use the same structure as other Rails projects. This
class may be handy one day.
2023-01-19 13:25:46 +11:00

38 lines
703 B
Ruby

# frozen_string_literal: true
# We need to configure MiniRacer to allow forking.
# Otherwise this spec hangs on CI.
# https://github.com/rubyjs/mini_racer#fork-safety
require "mini_racer"
MiniRacer::Platform.set_flags!(:single_threaded)
require 'spec_helper'
class TestJob < ApplicationJob
def initialize
@file = Tempfile.new("test-job-result")
super
end
def perform(message)
@file.write(message)
end
def result
@file.rewind
@file.read
end
end
describe JobProcessor do
describe ".perform_forked" do
let(:job) { TestJob.new }
it "executes a job" do
JobProcessor.perform_forked(job, "hello")
expect(job.result).to eq "hello"
end
end
end