File tree Expand file tree Collapse file tree 1 file changed +7
-13
lines changed
actionview/test/activerecord Expand file tree Collapse file tree 1 file changed +7
-13
lines changed Original file line number Diff line number Diff line change @@ -7,22 +7,16 @@ def setup
7
7
@view = ActionView ::Base
8
8
. with_empty_template_cache
9
9
. with_view_paths ( ActionController ::Base . view_paths , { } )
10
-
11
- @queries = [ ]
12
-
13
- @subscriber = ActiveSupport ::Notifications . subscribe ( "sql.active_record" ) do |*, payload |
14
- @queries << payload [ :sql ] unless %w[ SCHEMA TRANSACTION ] . include? ( payload [ :name ] )
15
- end
16
- end
17
-
18
- def teardown
19
- ActiveSupport ::Notifications . unsubscribe ( @subscriber )
20
10
end
21
11
22
12
def test_render_with_relation_collection
23
- @view . render partial : "topics/topic" , collection : Topic . all
13
+ notifications = capture_notifications ( "sql.active_record" ) do
14
+ @view . render partial : "topics/topic" , collection : Topic . all
15
+ end
16
+
17
+ queries = notifications . filter_map { _1 . payload [ :sql ] unless %w[ SCHEMA TRANSACTION ] . include? ( _1 . payload [ :name ] ) }
24
18
25
- assert_equal 1 , @ queries. size
26
- assert_equal 'SELECT "topics".* FROM "topics"' , @ queries[ 0 ]
19
+ assert_equal 1 , queries . size
20
+ assert_equal 'SELECT "topics".* FROM "topics"' , queries [ 0 ]
27
21
end
28
22
end
You can’t perform that action at this time.
0 commit comments