rails/activestorage/test
Jonathan Hefner 6aa26c30e2
Identify directly-uploaded blobs before saving the associated record
An Active Storage `Blob` must be identified before it can be reliably
validated.  For direct uploads, a `Blob` is identified when it is
attached, rather than when it is created.

Before this commit, the sequence of events when attaching a `Blob` was:

1. Find the `Blob`.
2. Assign the `Blob` to an `Attachment`.
3. Save the owner record.
4. Save the `Attachment`.
5. Identify the `Blob`'s true `content_type` from its file.
6. Save the `Blob`.

This meant that the owner record's validations might not see the
`Blob`'s true `content_type`.

After this commit, the sequence of events will be:

1. Find the `Blob`.
2. Identify the `Blob`'s true `content_type` from its file.
3. Assign the `Blob` to an `Attachment`.
4. Save the owner record.
5. Save the `Attachment`.
6. Save the `Blob`.

Thus the `Blob`'s true `content_type` will be available when running the
owner record's validations.
2020-08-11 18:08:09 -04:00
..
analyzer Fix typo s/:heigh/:height/ 2019-10-03 15:42:47 +09:00
controllers Use Active Record signed IDs in Active Storage 2020-07-04 21:09:00 -04:00
database touch parent model when an attachment is purged 2020-07-26 12:22:37 -05:00
dummy Unify raise_on_missing_translations for views and controllers 2020-05-20 02:42:59 +03:00
fixtures/files Use a smaller TIFF file as fixture 2019-07-27 23:08:49 +05:30
jobs Correct test class name 2019-09-28 10:31:26 -04:00
models Identify directly-uploaded blobs before saving the associated record 2020-08-11 18:08:09 -04:00
previewer Change video preview format from PNG to JPG 2018-05-23 14:32:34 -04:00
service Include Content-Length in signature for ActiveStorage direct upload 2020-05-15 14:32:19 -07:00
template url -> URL where apt except inside actionpack/ 2019-04-01 22:56:35 +05:30
javascript_package_test.rb Enforce that activestorage compiled JS is in sync with source code 2019-10-18 18:02:02 -07:00
test_helper.rb Fix attaching blobs via nested attributes 2020-08-04 00:26:27 -04:00