From 03afddd2eb0fb56716a8a9caa4456807706ce791 Mon Sep 17 00:00:00 2001 From: George Claghorn Date: Sat, 7 Jul 2018 17:04:47 -0400 Subject: 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. --- activestorage/test/test_helper.rb | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'activestorage/test/test_helper.rb') 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 -- cgit v1.2.3