Skip to content

Commit

Permalink
Merge pull request #48999 from higher-pixels/activestorage-transformj…
Browse files Browse the repository at this point in the history
…ob-nomethoderror

Fix NoMethodError in ActiveStorage::TransformJob for untracked variants.
  • Loading branch information
rafaelfranca committed Aug 23, 2023
2 parents 818bfc2 + 1d212dc commit 144dd24
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion activestorage/app/jobs/active_storage/transform_job.rb
Expand Up @@ -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
15 changes: 15 additions & 0 deletions activestorage/test/jobs/transform_job_test.rb
Expand Up @@ -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

0 comments on commit 144dd24

Please sign in to comment.