@@ -212,6 +212,18 @@ def teardown
212
212
ActiveRecord ::LogSubscriber . backtrace_cleaner = @original_backtrace_cleaner
213
213
end
214
214
215
+ def assert_user_facing_reflection ( model , association )
216
+ payloads = [ ]
217
+ callback = -> ( event ) { payloads << event . payload }
218
+
219
+ ActiveSupport ::Notifications . subscribed ( callback , "deprecated_association.active_record" ) do
220
+ model . new . send ( association )
221
+ end
222
+
223
+ assert_equal 1 , payloads . size
224
+ assert_equal model . reflect_on_association ( association ) , payloads [ 0 ] [ :reflection ]
225
+ end
226
+
215
227
test "report publishes an Active Support notification in :notify mode" do
216
228
payloads = [ ]
217
229
callback = -> ( event ) { payloads << event . payload }
@@ -234,5 +246,29 @@ def teardown
234
246
assert_equal __FILE__ , payload [ :backtrace ] [ -2 ] . path
235
247
assert_equal line , payload [ :backtrace ] [ -2 ] . lineno
236
248
end
249
+
250
+ test "has_many receives the user-facing reflection in the payload" do
251
+ assert_user_facing_reflection ( DATS ::Author , :deprecated_posts )
252
+ end
253
+
254
+ test "has_one receives the user-facing reflection in the payload" do
255
+ assert_user_facing_reflection ( DATS ::Author , :deprecated_post )
256
+ end
257
+
258
+ test "belongs_to receives the user-facing reflection in the payload" do
259
+ assert_user_facing_reflection ( DATS ::Bulb , :deprecated_car )
260
+ end
261
+
262
+ test "has_many :through receives the user-facing reflection in the payload" do
263
+ assert_user_facing_reflection ( DATS ::Author , :deprecated_has_many_through )
264
+ end
265
+
266
+ test "has_one :through receives the user-facing reflection in the payload" do
267
+ assert_user_facing_reflection ( DATS ::Author , :deprecated_has_one_through )
268
+ end
269
+
270
+ test "HABTM receives the user-facing reflection in the payload" do
271
+ assert_user_facing_reflection ( DATS ::Category , :deprecated_posts )
272
+ end
237
273
end
238
274
end
0 commit comments