Changesets can be listed by changeset number.
The Git repository is here.
- Revision:
- 173
- Log:
Updated to latest release of Beast according to the "getting started with
Beast" guide at:http://beast.caboo.se/forums/1/topics/381
This check-in includes frozen Edge Rails and has the beginnings of
configuration for the ROOL site included.
- Author:
- rool
- Date:
- Fri Mar 02 15:59:12 +0000 2007
- Size:
- 2909 Bytes
1 | require File.dirname(__FILE__) + '/../test_helper' |
2 | require 'sessions_controller' |
3 | |
4 | # Re-raise errors caught by the controller. |
5 | class SessionsController; def rescue_action(e) raise e end; end |
6 | |
7 | class SessionsControllerTest < Test::Unit::TestCase |
8 | all_fixtures |
9 | def setup |
10 | @controller = SessionsController.new |
11 | @request = ActionController::TestRequest.new |
12 | @response = ActionController::TestResponse.new |
13 | end |
14 | |
15 | def test_should_login |
16 | old = users(:aaron).last_seen_at |
17 | post :create, :login => 'aaron', :password => 'testy' |
18 | assert_redirected_to home_path |
19 | assert_equal users(:aaron).id, session[:user_id] |
20 | assert old != users(:aaron).reload.last_seen_at |
21 | assert_equal old, @controller.send(:last_active) |
22 | end |
23 | |
24 | def test_remember_me |
25 | post :create, :login => 'aaron', :password => 'testy', :remember_me => "1" |
26 | users(:aaron).reload |
27 | |
28 | assert cookies['login_token'] |
29 | assert_equal("1;#{users(:aaron).login_key}", cookies['login_token'].first) |
30 | assert_not_nil users(:aaron).login_key |
31 | assert_not_nil users(:aaron).login_key_expires_at |
32 | |
33 | #log off |
34 | post :destroy |
35 | assert cookies['login_token'].empty? |
36 | |
37 | # make sure it change if log in again |
38 | sleep 1 |
39 | old = users(:aaron).clone |
40 | post :create, :login => 'aaron', :password => 'testy', :remember_me => "1" |
41 | users(:aaron).reload |
42 | assert_not_equal(old.login_key, users(:aaron).login_key) |
43 | assert_not_equal(old.login_key_expires_at, users(:aaron).login_key_expires_at) |
44 | end |
45 | |
46 | def test_should_fail_login_for_unactivated_user |
47 | post :create, :login => 'kyle', :password => 'testy' |
48 | assert_response :success |
49 | assert_template 'new' |
50 | assert_nil session[:user_id] |
51 | end |
52 | |
53 | def test_should_fail_login |
54 | post :create, :login => 'aaron', :password => 'bad' |
55 | assert_response :success |
56 | assert_template 'new' |
57 | assert_nil session[:user_id] |
58 | end |
59 | |
60 | def test_should_logout |
61 | login_as :aaron |
62 | get :destroy |
63 | assert_redirected_to home_path |
64 | assert_nil session[:user_id] |
65 | end |
66 | |
67 | def test_should_find_no_user_from_empty_session |
68 | get :new |
69 | assert_equal 0, @controller.send(:current_user) |
70 | end |
71 | |
72 | def test_should_find_current_user_from_session |
73 | login_as :aaron |
74 | get :new |
75 | assert_equal users(:aaron), @controller.send(:current_user) |
76 | end |
77 | |
78 | def test_should_show_negative_logged_in_status |
79 | get :new |
80 | assert !@controller.send(:logged_in?) |
81 | end |
82 | |
83 | def test_should_show_positive_logged_in_status |
84 | login_as :aaron |
85 | get :new |
86 | assert @controller.send(:logged_in?) |
87 | end |
88 | |
89 | def test_should_show_negative_admin_status_when_logged_out |
90 | get :new |
91 | assert !@controller.send(:admin?) |
92 | end |
93 | |
94 | def test_should_show_negative_admin_status |
95 | login_as :sam |
96 | get :new |
97 | assert !@controller.send(:admin?) |
98 | end |
99 | |
100 | def test_should_show_positive_admin_status |
101 | login_as :aaron |
102 | get :new |
103 | assert @controller.send(:admin?) |
104 | end |
105 | end |