From c94bb9ba9a1df2e060e6f3debff57a0b7539be9f Mon Sep 17 00:00:00 2001
From: Matt Jankowski <matt@jankowski.online>
Date: Sat, 10 Jun 2023 12:27:35 -0400
Subject: [PATCH] Disable paperclip processing in specs (#25359)

---
 spec/models/media_attachment_spec.rb                    | 2 +-
 spec/rails_helper.rb                                    | 6 ++++++
 spec/support/examples/models/concerns/account_avatar.rb | 2 +-
 spec/support/examples/models/concerns/account_header.rb | 2 +-
 4 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/spec/models/media_attachment_spec.rb b/spec/models/media_attachment_spec.rb
index 4d4bc748f..2dfc6cf92 100644
--- a/spec/models/media_attachment_spec.rb
+++ b/spec/models/media_attachment_spec.rb
@@ -2,7 +2,7 @@
 
 require 'rails_helper'
 
-RSpec.describe MediaAttachment do
+RSpec.describe MediaAttachment, paperclip_processing: true do
   describe 'local?' do
     subject { media_attachment.local? }
 
diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb
index d7e2b5c18..f4113d565 100644
--- a/spec/rails_helper.rb
+++ b/spec/rails_helper.rb
@@ -94,6 +94,12 @@ RSpec.configure do |config|
     stub_jsonld_contexts!
   end
 
+  config.before(:each) do |example|
+    unless example.metadata[:paperclip_processing]
+      allow_any_instance_of(Paperclip::Attachment).to receive(:post_process).and_return(true) # rubocop:disable RSpec/AnyInstance
+    end
+  end
+
   config.after :each do
     Rails.cache.clear
     redis.del(redis.keys)
diff --git a/spec/support/examples/models/concerns/account_avatar.rb b/spec/support/examples/models/concerns/account_avatar.rb
index 2180f5273..8f5b81f3a 100644
--- a/spec/support/examples/models/concerns/account_avatar.rb
+++ b/spec/support/examples/models/concerns/account_avatar.rb
@@ -17,7 +17,7 @@ shared_examples 'AccountAvatar' do |fabricator|
     end
   end
 
-  describe 'base64-encoded files' do
+  describe 'base64-encoded files', paperclip_processing: true do
     let(:base64_attachment) { "data:image/jpeg;base64,#{Base64.encode64(attachment_fixture('attachment.jpg').read)}" }
     let(:account) { Fabricate(fabricator, avatar: base64_attachment) }
 
diff --git a/spec/support/examples/models/concerns/account_header.rb b/spec/support/examples/models/concerns/account_header.rb
index 77ee0e629..d65f54f00 100644
--- a/spec/support/examples/models/concerns/account_header.rb
+++ b/spec/support/examples/models/concerns/account_header.rb
@@ -1,7 +1,7 @@
 # frozen_string_literal: true
 
 shared_examples 'AccountHeader' do |fabricator|
-  describe 'base64-encoded files' do
+  describe 'base64-encoded files', paperclip_processing: true do
     let(:base64_attachment) { "data:image/jpeg;base64,#{Base64.encode64(attachment_fixture('attachment.jpg').read)}" }
     let(:account) { Fabricate(fabricator, header: base64_attachment) }