@@ -13,7 +13,7 @@ def test_payload_name_on_load
13
13
Book . create ( name : "test book" )
14
14
subscriber = ActiveSupport ::Notifications . subscribe ( "sql.active_record" ) do |*args |
15
15
event = ActiveSupport ::Notifications ::Event . new ( *args )
16
- if event . payload [ :sql ] . match "SELECT"
16
+ if event . payload [ :sql ] . match? ( "SELECT" )
17
17
assert_equal "Book Load" , event . payload [ :name ]
18
18
end
19
19
end
@@ -25,7 +25,7 @@ def test_payload_name_on_load
25
25
def test_payload_name_on_create
26
26
subscriber = ActiveSupport ::Notifications . subscribe ( "sql.active_record" ) do |*args |
27
27
event = ActiveSupport ::Notifications ::Event . new ( *args )
28
- if event . payload [ :sql ] . match "INSERT"
28
+ if event . payload [ :sql ] . match? ( "INSERT" )
29
29
assert_equal "Book Create" , event . payload [ :name ]
30
30
end
31
31
end
@@ -37,7 +37,7 @@ def test_payload_name_on_create
37
37
def test_payload_name_on_update
38
38
subscriber = ActiveSupport ::Notifications . subscribe ( "sql.active_record" ) do |*args |
39
39
event = ActiveSupport ::Notifications ::Event . new ( *args )
40
- if event . payload [ :sql ] . match "UPDATE"
40
+ if event . payload [ :sql ] . match? ( "UPDATE" )
41
41
assert_equal "Book Update" , event . payload [ :name ]
42
42
end
43
43
end
@@ -50,11 +50,10 @@ def test_payload_name_on_update
50
50
def test_payload_name_on_update_all
51
51
subscriber = ActiveSupport ::Notifications . subscribe ( "sql.active_record" ) do |*args |
52
52
event = ActiveSupport ::Notifications ::Event . new ( *args )
53
- if event . payload [ :sql ] . match "UPDATE"
53
+ if event . payload [ :sql ] . match? ( "UPDATE" )
54
54
assert_equal "Book Update All" , event . payload [ :name ]
55
55
end
56
56
end
57
- Book . create ( name : "test book" , format : "paperback" )
58
57
Book . update_all ( format : "ebook" )
59
58
ensure
60
59
ActiveSupport ::Notifications . unsubscribe ( subscriber ) if subscriber
@@ -63,7 +62,7 @@ def test_payload_name_on_update_all
63
62
def test_payload_name_on_destroy
64
63
subscriber = ActiveSupport ::Notifications . subscribe ( "sql.active_record" ) do |*args |
65
64
event = ActiveSupport ::Notifications ::Event . new ( *args )
66
- if event . payload [ :sql ] . match "DELETE"
65
+ if event . payload [ :sql ] . match? ( "DELETE" )
67
66
assert_equal "Book Destroy" , event . payload [ :name ]
68
67
end
69
68
end
@@ -73,10 +72,22 @@ def test_payload_name_on_destroy
73
72
ActiveSupport ::Notifications . unsubscribe ( subscriber ) if subscriber
74
73
end
75
74
75
+ def test_payload_name_on_delete_all
76
+ subscriber = ActiveSupport ::Notifications . subscribe ( "sql.active_record" ) do |*args |
77
+ event = ActiveSupport ::Notifications ::Event . new ( *args )
78
+ if event . payload [ :sql ] . match? ( "DELETE" )
79
+ assert_equal "Book Delete All" , event . payload [ :name ]
80
+ end
81
+ end
82
+ Book . delete_all
83
+ ensure
84
+ ActiveSupport ::Notifications . unsubscribe ( subscriber ) if subscriber
85
+ end
86
+
76
87
def test_payload_name_on_pluck
77
88
subscriber = ActiveSupport ::Notifications . subscribe ( "sql.active_record" ) do |*args |
78
89
event = ActiveSupport ::Notifications ::Event . new ( *args )
79
- if event . payload [ :sql ] . match "SELECT"
90
+ if event . payload [ :sql ] . match? ( "SELECT" )
80
91
assert_equal "Book Pluck" , event . payload [ :name ]
81
92
end
82
93
end
@@ -88,7 +99,7 @@ def test_payload_name_on_pluck
88
99
def test_payload_name_on_count
89
100
subscriber = ActiveSupport ::Notifications . subscribe ( "sql.active_record" ) do |*args |
90
101
event = ActiveSupport ::Notifications ::Event . new ( *args )
91
- if event . payload [ :sql ] . match "SELECT"
102
+ if event . payload [ :sql ] . match? ( "SELECT" )
92
103
assert_equal "Book Count" , event . payload [ :name ]
93
104
end
94
105
end
@@ -100,7 +111,7 @@ def test_payload_name_on_count
100
111
def test_payload_name_on_grouped_count
101
112
subscriber = ActiveSupport ::Notifications . subscribe ( "sql.active_record" ) do |*args |
102
113
event = ActiveSupport ::Notifications ::Event . new ( *args )
103
- if event . payload [ :sql ] . match "SELECT"
114
+ if event . payload [ :sql ] . match? ( "SELECT" )
104
115
assert_equal "Book Count" , event . payload [ :name ]
105
116
end
106
117
end
0 commit comments