Plugins - ActiveTest Authentication
Add to favoritesActiveTest Authentication
Description
The ActiveTest Authentication is an example, but fully functional, plugin for the ActiveTest::Controller subject. It gives you the ability to test that a controller’s action requires a user to be logged in.
It provides two behaviours (requires_login_on and accepts_login_on), two helper methods (login_as and logout), and two assertions (assert_requires_login and assert_accepts_login).
It assumes the following:
- You are using some variant of Acts As Authenticated (AAA).
- You have a users fixture.
- You are using a User model for your users.
- +@controller.current_user+ is set to a User object.
- +@controller.current_user+ is the proof of being logged in (as per AAA).
Example
class SomeControllerTest < ActiveTest::Controller
setup
def setup
login_as :admin
end
requires_login_on :index
accepts_login_on :index
end
http://www.mathewabonyi.com/articles/2006/11/19/two-activetest-plugins/
http://mabs29.googlecode.com/svn/trunk/plugins/active_test_authentication
Rails' (MIT)
Testing
