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.
This commit is contained in:
Maikel Linke
2023-10-20 16:58:29 +11:00
committed by Konrad
parent a110ee0982
commit 9f00817852
2 changed files with 16 additions and 1 deletions

View File

@@ -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

View File

@@ -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