Skip to content

Conversation

KapilSachdev
Copy link
Contributor

Fixes #39937

Summary

As described in the #39937, @controller is not always defined while testing routes, and thus the line

request = ActionController::TestRequest.create @controller.class

might raise warning: instance variable @controller not initialized in some instances.

This can be handled by checking defined?(controller) before accessing the instance variable.

controller = @controller if defined?(@controller)
request = ActionController::TestRequest.create controller&.class

Thanks to @ioquatix for the report (and solution as well :) )

@rails-bot rails-bot bot added the actionpack label Aug 11, 2020
@kamipo kamipo merged commit e4b5ced into rails:master Aug 12, 2020
@KapilSachdev KapilSachdev deleted the fix/uninitialized_instance_variable branch August 12, 2020 10:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

warning: instance variable @controller not initialized
2 participants