Skip to content

Commit 77b7835

Browse files
committed
Slient the deprecation warning for ActiveStorage.replace_on_assign_to_many logged in test cases
1 parent c89f152 commit 77b7835

File tree

1 file changed

+27
-23
lines changed

1 file changed

+27
-23
lines changed

activestorage/test/models/attached/many_test.rb

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -294,18 +294,20 @@ class ActiveStorage::ManyAttachedTest < ActiveSupport::TestCase
294294

295295
test "updating an existing record with attachments when appending on assign" do
296296
append_on_assign do
297-
@user.highlights.attach create_blob(filename: "funky.jpg"), create_blob(filename: "town.jpg")
297+
assert_deprecated do
298+
@user.highlights.attach create_blob(filename: "funky.jpg"), create_blob(filename: "town.jpg")
298299

299-
assert_difference -> { @user.reload.highlights.count }, +2 do
300-
@user.update! highlights: [ create_blob(filename: "whenever.jpg"), create_blob(filename: "wherever.jpg") ]
301-
end
300+
assert_difference -> { @user.reload.highlights.count }, +2 do
301+
@user.update! highlights: [ create_blob(filename: "whenever.jpg"), create_blob(filename: "wherever.jpg") ]
302+
end
302303

303-
assert_no_difference -> { @user.reload.highlights.count } do
304-
@user.update! highlights: [ ]
305-
end
304+
assert_no_difference -> { @user.reload.highlights.count } do
305+
@user.update! highlights: [ ]
306+
end
306307

307-
assert_no_difference -> { @user.reload.highlights.count } do
308-
@user.update! highlights: nil
308+
assert_no_difference -> { @user.reload.highlights.count } do
309+
@user.update! highlights: nil
310+
end
309311
end
310312
end
311313
end
@@ -760,20 +762,22 @@ def highlights
760762

761763
test "successfully attaches new blobs and destroys attachments marked for destruction via nested attributes" do
762764
append_on_assign do
763-
town_blob = create_blob(filename: "town.jpg")
764-
@user.highlights.attach(town_blob)
765-
@user.reload
766-
767-
racecar_blob = fixture_file_upload("racecar.jpg")
768-
attachment_id = town_blob.attachments.find_by!(record: @user).id
769-
@user.update(
770-
highlights: [racecar_blob],
771-
highlights_attachments_attributes: [{ id: attachment_id, _destroy: true }]
772-
)
773-
774-
assert @user.reload.highlights.attached?
775-
assert_equal 1, @user.highlights.count
776-
assert_equal "racecar.jpg", @user.highlights.blobs.first.filename.to_s
765+
assert_deprecated do
766+
town_blob = create_blob(filename: "town.jpg")
767+
@user.highlights.attach(town_blob)
768+
@user.reload
769+
770+
racecar_blob = fixture_file_upload("racecar.jpg")
771+
attachment_id = town_blob.attachments.find_by!(record: @user).id
772+
@user.update(
773+
highlights: [racecar_blob],
774+
highlights_attachments_attributes: [{ id: attachment_id, _destroy: true }]
775+
)
776+
777+
assert @user.reload.highlights.attached?
778+
assert_equal 1, @user.highlights.count
779+
assert_equal "racecar.jpg", @user.highlights.blobs.first.filename.to_s
780+
end
777781
end
778782
end
779783

0 commit comments

Comments
 (0)