mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-26 01:33:22 +00:00
Set ActiveJob configs and convert WelcomeEnterpriseJob to new format
This needs to be done for all jobs. Docs: https://guides.rubyonrails.org/v4.2/active_job_basics.html
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
WelcomeEnterpriseJob = Struct.new(:enterprise_id) do
|
||||
def perform
|
||||
class WelcomeEnterpriseJob < ActiveJob::Base
|
||||
def perform(enterprise_id)
|
||||
enterprise = Enterprise.find enterprise_id
|
||||
EnterpriseMailer.welcome(enterprise).deliver
|
||||
end
|
||||
|
||||
@@ -400,7 +400,7 @@ class Enterprise < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def send_welcome_email
|
||||
Delayed::Job.enqueue WelcomeEnterpriseJob.new(id)
|
||||
WelcomeEnterpriseJob.perform_later(id)
|
||||
end
|
||||
|
||||
def strip_url(url)
|
||||
|
||||
@@ -199,5 +199,7 @@ module Openfoodnetwork
|
||||
config.assets.precompile += ['*.jpg', '*.jpeg', '*.png', '*.gif' '*.svg']
|
||||
|
||||
config.active_support.escape_html_entities_in_json = true
|
||||
|
||||
config.active_job.queue_adapter = :delayed_job
|
||||
end
|
||||
end
|
||||
|
||||
@@ -51,6 +51,8 @@ Openfoodnetwork::Application.configure do
|
||||
require 'open_food_network/rack_request_blocker'
|
||||
# Make sure the middleware is inserted first in middleware chain
|
||||
config.middleware.insert_before('ActionDispatch::Static', 'RackRequestBlocker')
|
||||
|
||||
config.active_job.queue_adapter = :test
|
||||
end
|
||||
|
||||
# Allows us to use _url helpers in Rspec
|
||||
|
||||
@@ -8,6 +8,6 @@ describe WelcomeEnterpriseJob do
|
||||
expect(EnterpriseMailer).to receive(:welcome).with(enterprise).and_return(mail)
|
||||
expect(mail).to receive(:deliver)
|
||||
|
||||
run_job WelcomeEnterpriseJob.new(enterprise.id)
|
||||
WelcomeEnterpriseJob.perform_now(enterprise.id)
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user