@@ -22,8 +22,12 @@ def blob
22
22
23
23
def upload
24
24
case attachable
25
- when ActionDispatch ::Http ::UploadedFile , Rack :: Test :: UploadedFile
25
+ when ActionDispatch ::Http ::UploadedFile
26
26
blob . upload_without_unfurling ( attachable . open )
27
+ when Rack ::Test ::UploadedFile
28
+ blob . upload_without_unfurling (
29
+ attachable . respond_to? ( :open ) ? attachable . open : attachable
30
+ )
27
31
when Hash
28
32
blob . upload_without_unfurling ( attachable . fetch ( :io ) )
29
33
end
@@ -53,14 +57,22 @@ def find_or_build_blob
53
57
case attachable
54
58
when ActiveStorage ::Blob
55
59
attachable
56
- when ActionDispatch ::Http ::UploadedFile , Rack :: Test :: UploadedFile
60
+ when ActionDispatch ::Http ::UploadedFile
57
61
ActiveStorage ::Blob . build_after_unfurling (
58
62
io : attachable . open ,
59
63
filename : attachable . original_filename ,
60
64
content_type : attachable . content_type ,
61
65
record : record ,
62
66
service_name : attachment_service_name
63
67
)
68
+ when Rack ::Test ::UploadedFile
69
+ ActiveStorage ::Blob . build_after_unfurling (
70
+ io : attachable . respond_to? ( :open ) ? attachable . open : attachable ,
71
+ filename : attachable . original_filename ,
72
+ content_type : attachable . content_type ,
73
+ record : record ,
74
+ service_name : attachment_service_name
75
+ )
64
76
when Hash
65
77
ActiveStorage ::Blob . build_after_unfurling (
66
78
**attachable . reverse_merge (
0 commit comments