From 9f00817852b60cdef84db6ff886fe68af3cc7f59 Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Fri, 20 Oct 2023 16:58:29 +1100 Subject: [PATCH] Use source of truth of url_options for report URLs The ActionController options were not set in testing nor Sidekiq jobs. The now used config is always set in config/application.rb. --- app/jobs/application_job.rb | 2 +- spec/jobs/report_job_spec.rb | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) 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