File tree Expand file tree Collapse file tree 3 files changed +20
-0
lines changed
lib/active_storage/attached Expand file tree Collapse file tree 3 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -132,5 +132,9 @@ def purge_later
132
132
def attachment_changes #:nodoc:
133
133
@attachment_changes ||= { }
134
134
end
135
+
136
+ def reload ( *) #:nodoc:
137
+ super . tap { @attachment_changes = nil }
138
+ end
135
139
end
136
140
end
Original file line number Diff line number Diff line change @@ -467,6 +467,14 @@ class ActiveStorage::ManyAttachedTest < ActiveSupport::TestCase
467
467
end
468
468
end
469
469
470
+ test "clearing change on reload" do
471
+ @user . highlights = [ create_blob ( filename : "funky.jpg" ) , create_blob ( filename : "town.jpg" ) ]
472
+ assert @user . highlights . attached?
473
+
474
+ @user . reload
475
+ assert_not @user . highlights . attached?
476
+ end
477
+
470
478
test "overriding attached reader" do
471
479
@user . highlights . attach create_blob ( filename : "funky.jpg" ) , create_blob ( filename : "town.jpg" )
472
480
Original file line number Diff line number Diff line change @@ -427,6 +427,14 @@ class ActiveStorage::OneAttachedTest < ActiveSupport::TestCase
427
427
end
428
428
end
429
429
430
+ test "clearing change on reload" do
431
+ @user . avatar = create_blob ( filename : "funky.jpg" )
432
+ assert @user . avatar . attached?
433
+
434
+ @user . reload
435
+ assert_not @user . avatar . attached?
436
+ end
437
+
430
438
test "overriding attached reader" do
431
439
@user . avatar . attach create_blob ( filename : "funky.jpg" )
432
440
You can’t perform that action at this time.
0 commit comments