File tree Expand file tree Collapse file tree 5 files changed +20
-29
lines changed
activerecord/test/cases/associations
activestorage/test/analyzer
activesupport/test/cache/stores Expand file tree Collapse file tree 5 files changed +20
-29
lines changed Original file line number Diff line number Diff line change @@ -1147,12 +1147,8 @@ def test_association_loading_notification
1147
1147
end
1148
1148
1149
1149
def test_base_messages
1150
- payload = capture_notifications ( "instantiation.active_record" ) do
1151
- Developer . all . to_a
1152
- end . first . payload
1153
-
1154
- assert_equal Developer . all . to_a . count , payload [ :record_count ]
1155
- assert_equal Developer . name , payload [ :class_name ]
1150
+ expected_payload = { record_count : Developer . all . to_a . count , class_name : Developer . name }
1151
+ assert_notification ( "instantiation.active_record" , expected_payload ) { Developer . all . to_a }
1156
1152
end
1157
1153
1158
1154
def test_load_with_sti_sharing_association
Original file line number Diff line number Diff line change @@ -18,13 +18,12 @@ class ActiveStorage::Analyzer::AudioAnalyzerTest < ActiveSupport::TestCase
18
18
end
19
19
20
20
test "instrumenting analysis" do
21
- events = capture_notifications ( "analyze.active_storage" ) do
22
- assert_notifications_count ( "analyze.active_storage" , 1 ) do
23
- blob = create_file_blob ( filename : "audio.mp3" , content_type : "audio/mp3" )
21
+ blob = create_file_blob ( filename : "audio.mp3" , content_type : "audio/mp3" )
22
+
23
+ assert_notifications_count ( "analyze.active_storage" , 1 ) do
24
+ assert_notification ( "analyze.active_storage" , analyzer : "ffprobe" ) do
24
25
blob . analyze
25
26
end
26
27
end
27
-
28
- assert_equal ( { analyzer : "ffprobe" } , events . first . payload )
29
28
end
30
29
end
Original file line number Diff line number Diff line change @@ -47,14 +47,14 @@ class ActiveStorage::Analyzer::ImageAnalyzer::ImageMagickTest < ActiveSupport::T
47
47
end
48
48
49
49
test "instrumenting analysis" do
50
- analyze_with_image_magick do
51
- events = capture_notifications ( "analyze.active_storage" ) do
52
- blob = create_file_blob ( filename : "racecar.jpg" , content_type : "image/jpeg" )
53
- blob . analyze
54
- end
50
+ blob = create_file_blob ( filename : "racecar.jpg" , content_type : "image/jpeg" )
55
51
56
- assert_equal 1 , events . size
57
- assert_equal ( { analyzer : "mini_magick" } , events . first . payload )
52
+ assert_notifications_count ( "analyze.active_storage" , 1 ) do
53
+ assert_notification ( "analyze.active_storage" , analyzer : "mini_magick" ) do
54
+ analyze_with_image_magick do
55
+ blob . analyze
56
+ end
57
+ end
58
58
end
59
59
end
60
60
Original file line number Diff line number Diff line change @@ -87,12 +87,12 @@ class ActiveStorage::Analyzer::VideoAnalyzerTest < ActiveSupport::TestCase
87
87
end
88
88
89
89
test "instrumenting analysis" do
90
- events = capture_notifications ( "analyze.active_storage" ) do
91
- blob = create_file_blob ( filename : "video_without_audio_stream.mp4" , content_type : "video/mp4" )
92
- blob . analyze
93
- end
90
+ blob = create_file_blob ( filename : "video.mp4" , content_type : "video/mp4" )
94
91
95
- assert_equal 1 , events . size
96
- assert_equal ( { analyzer : "ffprobe" } , events . first . payload )
92
+ assert_notifications_count ( "analyze.active_storage" , 1 ) do
93
+ assert_notification ( "analyze.active_storage" , analyzer : "ffprobe" ) do
94
+ blob . analyze
95
+ end
96
+ end
97
97
end
98
98
end
Original file line number Diff line number Diff line change @@ -44,13 +44,9 @@ def test_cleanup_instrumentation
44
44
size = 3
45
45
size . times { |i | @cache . write ( i . to_s , i ) }
46
46
47
- events = capture_notifications ( "cache_cleanup.active_support" ) do
47
+ assert_notification ( "cache_cleanup.active_support" , size : size , store : @cache . class . name ) do
48
48
@cache . cleanup
49
49
end
50
-
51
- assert_equal %w[ cache_cleanup.active_support ] , events . map ( &:name )
52
- assert_equal size , events [ 0 ] . payload [ :size ]
53
- assert_equal @cache . class . name , events [ 0 ] . payload [ :store ]
54
50
end
55
51
56
52
def test_nil_coder_bypasses_mutation_safeguard
You can’t perform that action at this time.
0 commit comments