Skip to content

Instantly share code, notes, and snippets.

@mahemoff
Created January 27, 2014 16:08
Show Gist options
  • Save mahemoff/8651382 to your computer and use it in GitHub Desktop.
Save mahemoff/8651382 to your computer and use it in GitHub Desktop.
A convenience superlass for controller tests, if using Devise
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