Created
January 27, 2014 16:08
-
-
Save mahemoff/8651382 to your computer and use it in GitHub Desktop.
A convenience superlass for controller tests, if using Devise
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ControllerTestCase < ActionController::TestCase | |
include Devise::TestHelpers | |
include Warden::Test::Helpers | |
def setup | |
Warden.test_mode! | |
self.do_setup | |
end | |
def confirm_and_login(user) | |
# might also set password here if not set in yml | |
user.confirm! | |
sign_in user | |
end | |
def do_setup | |
# override this for individual tests | |
end | |
def teardown | |
Warden.test_reset! | |
self.do_teardown | |
end | |
def do_teardown | |
# override this for individual tests | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment