File tree Expand file tree Collapse file tree 5 files changed +18
-23
lines changed Expand file tree Collapse file tree 5 files changed +18
-23
lines changed Original file line number Diff line number Diff line change @@ -18,12 +18,13 @@ class ActiveStorage::Analyzer::AudioAnalyzerTest < ActiveSupport::TestCase
18
18
end
19
19
20
20
test "instrumenting analysis" do
21
- events = subscribe_events_from ( "analyze.active_storage" )
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" )
24
+ blob . analyze
25
+ end
26
+ end
22
27
23
- blob = create_file_blob ( filename : "audio.mp3" , content_type : "audio/mp3" )
24
- blob . analyze
25
-
26
- assert_equal 1 , events . size
27
28
assert_equal ( { analyzer : "ffprobe" } , events . first . payload )
28
29
end
29
30
end
Original file line number Diff line number Diff line change @@ -48,10 +48,10 @@ class ActiveStorage::Analyzer::ImageAnalyzer::ImageMagickTest < ActiveSupport::T
48
48
49
49
test "instrumenting analysis" do
50
50
analyze_with_image_magick do
51
- events = subscribe_events_from ( "analyze.active_storage" )
52
-
53
- blob = create_file_blob ( filename : "racecar.jpg" , content_type : "image/jpeg" )
54
- blob . analyze
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
55
55
56
56
assert_equal 1 , events . size
57
57
assert_equal ( { analyzer : "mini_magick" } , events . first . payload )
Original file line number Diff line number Diff line change @@ -48,10 +48,10 @@ class ActiveStorage::Analyzer::ImageAnalyzer::VipsTest < ActiveSupport::TestCase
48
48
49
49
test "instrumenting analysis" do
50
50
analyze_with_vips do
51
- events = subscribe_events_from ( "analyze.active_storage" )
52
-
53
- blob = create_file_blob ( filename : "racecar.jpg" , content_type : "image/jpeg" )
54
- blob . analyze
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
55
55
56
56
assert_equal 1 , events . size
57
57
assert_equal ( { analyzer : "vips" } , events . first . payload )
Original file line number Diff line number Diff line change @@ -87,10 +87,10 @@ class ActiveStorage::Analyzer::VideoAnalyzerTest < ActiveSupport::TestCase
87
87
end
88
88
89
89
test "instrumenting analysis" do
90
- events = subscribe_events_from ( "analyze.active_storage" )
91
-
92
- blob = create_file_blob ( filename : "video_without_audio_stream.mp4" , content_type : "video/mp4" )
93
- blob . analyze
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
94
94
95
95
assert_equal 1 , events . size
96
96
assert_equal ( { analyzer : "ffprobe" } , events . first . payload )
Original file line number Diff line number Diff line change @@ -114,12 +114,6 @@ def with_raise_on_open_redirects(service)
114
114
ActionController ::Base . raise_on_open_redirects = old_raise_on_open_redirects
115
115
ActiveStorage ::Blob . service = old_service
116
116
end
117
-
118
- def subscribe_events_from ( name )
119
- events = [ ]
120
- ActiveSupport ::Notifications . subscribe ( name ) { |event | events << event }
121
- events
122
- end
123
117
end
124
118
125
119
require "global_id"
You can’t perform that action at this time.
0 commit comments