From 1d212dc357e46c364cb67d02b042b5b25fc7ce4a Mon Sep 17 00:00:00 2001 From: Bryan Traywick <42215+bryantraywick@users.noreply.github.com> Date: Tue, 22 Aug 2023 12:42:12 -0400 Subject: [PATCH] Fix NoMethodError in ActiveStorage::TransformJob for untracked variants. --- .../app/jobs/active_storage/transform_job.rb | 2 +- activestorage/test/jobs/transform_job_test.rb | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/activestorage/app/jobs/active_storage/transform_job.rb b/activestorage/app/jobs/active_storage/transform_job.rb index f7f260542b49e..d2c8bffe1ff67 100644 --- a/activestorage/app/jobs/active_storage/transform_job.rb +++ b/activestorage/app/jobs/active_storage/transform_job.rb @@ -7,6 +7,6 @@ class ActiveStorage::TransformJob < ActiveStorage::BaseJob retry_on ActiveStorage::IntegrityError, attempts: 10, wait: :exponentially_longer def perform(blob, transformations) - blob.variant(transformations).process + blob.variant(transformations).processed end end diff --git a/activestorage/test/jobs/transform_job_test.rb b/activestorage/test/jobs/transform_job_test.rb index c813caeba65c9..21e5d42f8485f 100644 --- a/activestorage/test/jobs/transform_job_test.rb +++ b/activestorage/test/jobs/transform_job_test.rb @@ -15,4 +15,19 @@ class ActiveStorage::TransformJobTest < ActiveJob::TestCase end end end + + test "creates variant when untracked" do + @was_tracking, ActiveStorage.track_variants = ActiveStorage.track_variants, false + transformations = { resize_to_limit: [100, 100] } + + begin + assert_changes -> { @blob.variant(transformations).send(:processed?) }, from: false, to: true do + perform_enqueued_jobs do + ActiveStorage::TransformJob.perform_later @blob, transformations + end + end + ensure + ActiveStorage.track_variants = @was_tracking + end + end end