aboutsummaryrefslogtreecommitdiffstats
path: root/activestorage/test/models/attached
Commit message (Collapse)AuthorAgeFilesLines
* Preserve existing attachment assignment behavior for upgraded appsGeorge Claghorn2019-07-201-0/+26
| | | | | | | | | Assigning to a collection of attachments appends rather than replacing, as in 5.2. Existing 5.2 apps that rely on this behavior will no longer break when they're upgraded to 6.0. For apps generated on 6.0 or newer, assigning replaces the existing attachments in the collection. #attach should be used to add new attachments to the collection without removing existing ones. I expect that we'll deprecate the old behavior in 6.1. Closes #36374.
* Mirror direct uploadsGeorge Claghorn2019-05-221-58/+0
|
* [ActiveStorage] Ensure that the `_blob` association is properly loaded when ↵Abhishek Chandrasekhar2019-02-262-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | attaching `::One` Consider a model with `One` and `Many` attachments configured: class User < ActiveRecord::Base has_one_attached :avatar has_many_attached :highlights end === One Attachment After attaching `One` attachment (`:avatar`), we can see that the associated `_blob` record (`:avatar_blob`) still returns as `nil`. user.avatar.attach(blob) user.avatar_attachment.present? => true user.avatar_blob.present? => false # Incorrect! This is a false negative. It happens because after the attachment and blob are built: 1. The record already has its `_blob` association loaded, as `nil` 2. the `::Attachment` is associated with the record but the `::Blob` only gets associated with the `::Attachment`, not the record itself In reality, the blob does in fact exist. We can verify this as follows: user.avatar.attach(blob) user.avatar_attachment.blob.present? => true # Blob does exist! The fix in this change is to simply assign the `::Blob` when assigning the `::Attachment`. After this fix is applied, we correctly observe: user.avatar.attach(blob) user.avatar_attachment.present? => true user.avatar_blob.present? => true # Woohoo! === Many Attachments We don't see this issue with `Many` attachments because the `_blob` association is already loaded as part of attaching more/newer blobs. user.highlights.attach(blob) user.highlights_attachments.any? => true user.highlights_blobs.any? => true
* Module#{define_method,alias_method,undef_method,remove_method} become public ↵Ryuta Kamizono2018-12-212-2/+2
| | | | | | since Ruby 2.5 https://bugs.ruby-lang.org/issues/14133
* Ignore ActiveRecord::InvalidForeignKey in ActiveStorage::Blob#purgeJasper Martin2018-07-262-0/+91
| | | Do nothing instead of raising an error when it’s called on an attached blob.
* Add a foreign-key constraint to the attachments table for blobsGeorge Claghorn2018-07-192-2/+2
|
* Remove unnecessary tapGeorge Claghorn2018-07-171-10/+8
|
* Fix replacing many attachments via assign and attachGeorge Claghorn2018-07-171-0/+36
|
* Correct test nameGeorge Claghorn2018-07-161-1/+1
|
* Fix that successive ActiveStorage::Attached::Many#attach calls would ↵George Claghorn2018-07-161-26/+11
| | | | overwrite previous attachments
* Test removing attachments via #attachGeorge Claghorn2018-07-162-12/+59
|
* Clear attachment changes on reloadGeorge Claghorn2018-07-132-0/+16
|
* Implement ActiveStorage::Attached::{One,Many}#attach in terms of changesGeorge Claghorn2018-07-132-29/+153
|
* Fix that detaching could purgeGeorge Claghorn2018-07-132-0/+32
|
* Fix analyzing new blobs from uploaded files on attachGeorge Claghorn2018-07-132-0/+116
|
* Raise an ArgumentError instead of a RuntimeErrorGeorge Claghorn2018-07-082-2/+2
|
* Store newly-uploaded files on save rather than assignmentGeorge Claghorn2018-07-072-0/+664