Add Delayed::Job #134

Closed
croaky opened this Issue Jan 10, 2013 · 2 comments

1 participant

@croaky
thoughtbot, inc. member

We want to deliver emails in the background of all our Rails apps. Other long-running processes that don't need to block the HTTP request/response cycle can also be done in the background.

# spec/spec_helper.rb
RSpec.configure do |config|
  config.around(:each, type: :feature) do |example|
    run_background_jobs_immediately do
      example.run
    end
  end

  config.include BackgroundJobs
end

# spec/support/background_jobs.rb
module BackgroundJobs
  def run_background_jobs_immediately
    delay_jobs = Delayed::Worker.delay_jobs
    Delayed::Worker.delay_jobs = false
    yield
    Delayed::Worker.delay_jobs = delay_jobs
  end
end
@croaky
thoughtbot, inc. member
@croaky
thoughtbot, inc. member

Done in #166.

@croaky croaky closed this Apr 12, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment