提交 9e06289a 编写于 作者: G George Claghorn 提交者: George Claghorn

Switch to the writer DB to generate ASt previews

上级 34d66ca6
......@@ -74,7 +74,11 @@ def processed?
end
def process
previewer.preview { |attachable| image.attach(attachable) }
previewer.preview do |attachable|
ActiveRecord::Base.connected_to(role: ActiveRecord::Base.writing_role) do
image.attach(attachable)
end
end
end
def variant
......
......@@ -37,4 +37,15 @@ class ActiveStorage::PreviewTest < ActiveSupport::TestCase
blob.preview resize: "640x280"
end
end
test "previewing on the writer DB" do
blob = create_file_blob(filename: "report.pdf", content_type: "application/pdf")
# Simulate a selector middleware switching to a read-only replica.
ActiveRecord::Base.connection_handler.while_preventing_writes do
blob.preview(resize: "640x280").processed
end
assert blob.reload.preview_image.attached?
end
end
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册