Skip to content

Commit 5e83ad3

Browse files
authored
Merge pull request rails#42988 from abhaynikam/fix-active-storage-test-warnings
Fixes deprecation warning logged in the test cases
2 parents ee98178 + 1372200 commit 5e83ad3

File tree

3 files changed

+28
-24
lines changed

3 files changed

+28
-24
lines changed
31.4 MB
Binary file not shown.

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

activestorage/test/service/disk_service_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class ActiveStorage::Service::DiskServiceTest < ActiveSupport::TestCase
5151

5252
test "URL generation keeps working with ActiveStorage::Current.host set" do
5353
ActiveStorage::Current.url_options = nil
54-
ActiveStorage::Current.host = "https://example.com"
54+
assert_deprecated { ActiveStorage::Current.host = "https://example.com" }
5555

5656
original_url_options = Rails.application.routes.default_url_options.dup
5757
Rails.application.routes.default_url_options.merge!(protocol: "http", host: "test.example.com", port: 3001)

0 commit comments

Comments
 (0)