aboutsummaryrefslogtreecommitdiffstats
path: root/activestorage/test/test_helper.rb
diff options
context:
space:
mode:
authorGeorge Claghorn <george@basecamp.com>2018-07-07 17:04:47 -0400
committerGeorge Claghorn <george@basecamp.com>2018-07-07 17:09:31 -0400
commit03afddd2eb0fb56716a8a9caa4456807706ce791 (patch)
tree8382eba357d69f6d2acf776582c2113ed60c71c9 /activestorage/test/test_helper.rb
parent13c66d4626707fcc6c67ec6b197bb1e0be317b84 (diff)
downloadrails-03afddd2eb0fb56716a8a9caa4456807706ce791.tar.gz
rails-03afddd2eb0fb56716a8a9caa4456807706ce791.tar.bz2
rails-03afddd2eb0fb56716a8a9caa4456807706ce791.zip
Fix that models can clobber each others' attachment reflections
Consider the following model definitions: class User < ApplicationRecord has_one_attached :avatar end class Group < ApplicationRecord has_one_attached :avatar end If you attempt to reflect on the User model's avatar attachment via User.reflect_on_attachment, you could receive a reflection for the Group model's avatar attachment. Fix this by ensuring that each model class uses its own Hash object to track attachment reflections.
Diffstat (limited to 'activestorage/test/test_helper.rb')
-rw-r--r--activestorage/test/test_helper.rb4
1 files changed, 4 insertions, 0 deletions
diff --git a/activestorage/test/test_helper.rb b/activestorage/test/test_helper.rb
index 573a8e0b0b..9985a76832 100644
--- a/activestorage/test/test_helper.rb
+++ b/activestorage/test/test_helper.rb
@@ -92,3 +92,7 @@ class User < ActiveRecord::Base
has_many_attached :highlights
has_many_attached :vlogs, dependent: false
end
+
+class Group < ActiveRecord::Base
+ has_one_attached :avatar
+end