diff --git a/app/jobs/application_job.rb b/app/jobs/application_job.rb index 6411c58c0b..5fd395e89f 100644 --- a/app/jobs/application_job.rb +++ b/app/jobs/application_job.rb @@ -12,6 +12,6 @@ class ApplicationJob < ActiveJob::Base def enable_active_storage_urls ActiveStorage::Current.url_options ||= - Rails.application.config.action_controller.default_url_options + Rails.application.routes.default_url_options end end diff --git a/spec/jobs/report_job_spec.rb b/spec/jobs/report_job_spec.rb index b37b19540a..14807c6578 100644 --- a/spec/jobs/report_job_spec.rb +++ b/spec/jobs/report_job_spec.rb @@ -3,6 +3,8 @@ require 'spec_helper' describe ReportJob do + include CableReady::Broadcaster + let(:report_args) { { report_class:, user:, params:, format:, filename: } } @@ -32,6 +34,19 @@ describe ReportJob do expect_csv_report end + it "notifies Cable Ready when the report is done" do + channel = ScopedChannel.for_id("123") + with_channel = report_args.merge(channel:) + + ReportJob.perform_later(**with_channel) + + expect(cable_ready[channel]).to receive(:broadcast).and_call_original + + expect { + perform_enqueued_jobs(only: ReportJob) + }.to change { ActiveStorage::Blob.count } + end + it "triggers an email when the report is done" do # Setup test data which also triggers emails: report_args