Skip to content

Commit 5cfc494

Browse files
committed
Ruby: Test render inside redirect_to
This test shows that we correctly identify redirect_to and render calls inside respond_to blocks.
1 parent 155b64d commit 5cfc494

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

ruby/ql/test/library-tests/frameworks/action_controller/ActionController.expected

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
actionControllerControllerClasses
2-
| controllers/comments_controller.rb:1:1:40:3 | CommentsController |
2+
| controllers/comments_controller.rb:1:1:45:3 | CommentsController |
33
| controllers/foo/bars_controller.rb:3:1:46:3 | BarsController |
44
| controllers/photos_controller.rb:1:1:4:3 | PhotosController |
55
| controllers/posts_controller.rb:1:1:10:3 | PostsController |
@@ -10,7 +10,7 @@ actionControllerControllerClasses
1010
| params_flow.rb:1:1:151:3 | MyController |
1111
actionControllerActionMethods
1212
| controllers/comments_controller.rb:2:3:36:5 | index |
13-
| controllers/comments_controller.rb:38:3:39:5 | show |
13+
| controllers/comments_controller.rb:38:3:44:5 | show |
1414
| controllers/foo/bars_controller.rb:5:3:7:5 | index |
1515
| controllers/foo/bars_controller.rb:9:3:18:5 | show_debug |
1616
| controllers/foo/bars_controller.rb:20:3:24:5 | show |
@@ -251,10 +251,12 @@ cookiesCalls
251251
cookiesSources
252252
| controllers/foo/bars_controller.rb:10:27:10:33 | call to cookies |
253253
redirectToCalls
254+
| controllers/comments_controller.rb:40:21:40:49 | call to redirect_to |
254255
| controllers/foo/bars_controller.rb:17:5:17:30 | call to redirect_to |
255256
| controllers/foo/bars_controller.rb:27:5:27:39 | call to redirect_back_or_to |
256257
| controllers/foo/bars_controller.rb:31:5:31:56 | call to redirect_back |
257258
renderCalls
259+
| controllers/comments_controller.rb:42:21:42:64 | call to render |
258260
| controllers/foo/bars_controller.rb:6:5:6:37 | call to render |
259261
| controllers/foo/bars_controller.rb:23:5:23:76 | call to render |
260262
| controllers/foo/bars_controller.rb:35:5:35:33 | call to render |

ruby/ql/test/library-tests/frameworks/action_controller/controllers/comments_controller.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,10 @@ def index
3636
end
3737

3838
def show
39+
respond_to do |format|
40+
format.html { redirect_to(comment_view_url) }
41+
format.json
42+
format.xml { render xml: @comment.to_xml(include: @photo) }
43+
end
3944
end
4045
end

0 commit comments

Comments
 (0)