Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable strict loading on ActiveStorage::Attached::Changes #41461

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def upload
end

def save
record.strict_loading!(false)
record.public_send("#{name}_attachment=", attachment)
record.public_send("#{name}_blob=", blob)
end
Expand Down
9 changes: 9 additions & 0 deletions activestorage/test/models/attachment_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,15 @@ class ActiveStorage::AttachmentTest < ActiveSupport::TestCase
assert_equal blob, ActiveStorage::Blob.find_signed!(signed_id_generated_old_way)
end

test "attaching with strict_loading and getting a signed blob ID from an attachment" do
blob = create_blob
@user.strict_loading!(true)
@user.avatar.attach(blob)

signed_id = @user.avatar.signed_id
assert_equal blob, ActiveStorage::Blob.find_signed(signed_id)
end

private
def assert_blob_identified_before_owner_validated(owner, blob, content_type)
validated_content_type = nil
Expand Down