diff options
author | George Claghorn <george@basecamp.com> | 2018-07-13 14:48:45 -0400 |
---|---|---|
committer | George Claghorn <george@basecamp.com> | 2018-07-13 14:48:45 -0400 |
commit | bd5eba1adff8fa72429f5889ae26097e9756ceb0 (patch) | |
tree | 22690f0a6db99483ee7c6556577abc2e3370eae7 /activestorage/test/models | |
parent | 28db8ba60e726d695cf35710cc43ea45966464e9 (diff) | |
download | rails-bd5eba1adff8fa72429f5889ae26097e9756ceb0.tar.gz rails-bd5eba1adff8fa72429f5889ae26097e9756ceb0.tar.bz2 rails-bd5eba1adff8fa72429f5889ae26097e9756ceb0.zip |
Clear attachment changes on reload
Diffstat (limited to 'activestorage/test/models')
-rw-r--r-- | activestorage/test/models/attached/many_test.rb | 8 | ||||
-rw-r--r-- | activestorage/test/models/attached/one_test.rb | 8 |
2 files changed, 16 insertions, 0 deletions
diff --git a/activestorage/test/models/attached/many_test.rb b/activestorage/test/models/attached/many_test.rb index 719032786b..fc89dae658 100644 --- a/activestorage/test/models/attached/many_test.rb +++ b/activestorage/test/models/attached/many_test.rb @@ -467,6 +467,14 @@ class ActiveStorage::ManyAttachedTest < ActiveSupport::TestCase end end + test "clearing change on reload" do + @user.highlights = [ create_blob(filename: "funky.jpg"), create_blob(filename: "town.jpg") ] + assert @user.highlights.attached? + + @user.reload + assert_not @user.highlights.attached? + end + test "overriding attached reader" do @user.highlights.attach create_blob(filename: "funky.jpg"), create_blob(filename: "town.jpg") diff --git a/activestorage/test/models/attached/one_test.rb b/activestorage/test/models/attached/one_test.rb index 6d2b8eaaf6..33f9122644 100644 --- a/activestorage/test/models/attached/one_test.rb +++ b/activestorage/test/models/attached/one_test.rb @@ -427,6 +427,14 @@ class ActiveStorage::OneAttachedTest < ActiveSupport::TestCase end end + test "clearing change on reload" do + @user.avatar = create_blob(filename: "funky.jpg") + assert @user.avatar.attached? + + @user.reload + assert_not @user.avatar.attached? + end + test "overriding attached reader" do @user.avatar.attach create_blob(filename: "funky.jpg") |