Changesets can be listed by changeset number.
The Git repository is here.
- Revision:
- 193
- Log:
First stage commit of Typo 4.1, modified for the ROOL site.
Includes all local modifications but a final pass needs to be
made to delete any files left over from earlier Typo versions
that shouldn't be here anymore. See the 'tags' section of the
repository for a clean Typo 4.1 tree.Note that symlinks to shared files in the RISC OS Open theme
directory have been deliberately included this time around; I
decided that on balance it was better to leave them in as
placeholders, since unlike symlinks in app/views/shared, the
Typo theme structure is not a standard Rails concept.
- Author:
- rool
- Date:
- Wed Apr 04 18:51:02 +0100 2007
- Size:
- 4475 Bytes
1 | require File.dirname(__FILE__) + '/../spec_helper' |
2 | |
3 | context 'A successfully authenticated login' do |
4 | controller_name :accounts |
5 | |
6 | setup do |
7 | @user = mock("user") |
8 | @user.stub!(:new_record?).and_return(false) |
9 | @user.stub!(:reload).and_return(@user) |
10 | User.stub!(:authenticate).and_return(@user) |
11 | post 'login', { :user_login => 'bob', :password => 'test' } |
12 | end |
13 | |
14 | specify 'session gets a user' do |
15 | request.session[:user].should == @user |
16 | end |
17 | |
18 | specify 'cookies[:typoapp_is_admin] should == "yes"' do |
19 | cookies['typoapp_is_admin'].should == ['yes'] |
20 | end |
21 | |
22 | specify 'redirects to /bogus/location' do |
23 | request.session[:return_to] = '/bogus/location' |
24 | controller.should_redirect_to '/bogus/location' |
25 | post 'login', { :user_login => 'bob', :password => 'test' } |
26 | end |
27 | end |
28 | |
29 | context 'Login gets the wrong password' do |
30 | controller_name :accounts |
31 | |
32 | setup do |
33 | User.stub!(:authenticate).and_return(nil) |
34 | post 'login', {:user_login => 'bob', :password => 'test'} |
35 | end |
36 | |
37 | specify 'no user in goes in the session' do |
38 | response.session[:user].should_be nil |
39 | end |
40 | |
41 | specify 'login should == "bob"' do |
42 | assigns[:login].should == 'bob' |
43 | end |
44 | |
45 | specify 'cookies[:typoapp_is_admin] should be blank' do |
46 | response.cookies[:typoapp_is_admin].should_be_blank |
47 | end |
48 | |
49 | specify 'should render login action' do |
50 | controller.should_render(:login) |
51 | post 'login', {:user_login => 'bob', :password => 'test'} |
52 | end |
53 | end |
54 | |
55 | context 'GET /login' do |
56 | controller_name :accounts |
57 | |
58 | specify 'should render action :login' do |
59 | controller.should_render(:login) |
60 | get 'login' |
61 | assigns[:login].should_be_nil |
62 | end |
63 | end |
64 | |
65 | context 'GET signup and >0 existing user' do |
66 | controller_name :accounts |
67 | |
68 | setup do |
69 | User.stub!(:count).and_return(1) |
70 | end |
71 | |
72 | specify 'should redirect to login' do |
73 | controller.should_redirect_to :action => 'login' |
74 | get 'signup' |
75 | end |
76 | end |
77 | |
78 | context 'POST signup and >0 existing user' do |
79 | controller_name :accounts |
80 | |
81 | setup do |
82 | User.stub!(:count).and_return(1) |
83 | end |
84 | |
85 | specify 'should redirect to login' do |
86 | controller.should_redirect_to :action => 'login' |
87 | post 'signup', params |
88 | end |
89 | |
90 | def params |
91 | {'user' => {'login' => 'newbob', 'password' => 'newpassword', |
92 | 'password_confirmation' => 'newpassword'}} |
93 | end |
94 | end |
95 | |
96 | context 'GET signup with 0 existing users' do |
97 | controller_name :accounts |
98 | |
99 | setup do |
100 | User.stub!(:count).and_return(0) |
101 | @user = mock("user") |
102 | @user.stub!(:reload).and_return(@user) |
103 | User.stub!(:new).and_return(@user) |
104 | end |
105 | |
106 | specify 'sets @user' do |
107 | get 'signup' |
108 | assigns[:user].should == @user |
109 | end |
110 | |
111 | specify 'renders action signup' do |
112 | controller.should_render :signup |
113 | get 'signup' |
114 | end |
115 | end |
116 | |
117 | context 'POST signup with 0 existing users' do |
118 | controller_name :accounts |
119 | |
120 | setup do |
121 | User.stub!(:count).and_return(0) |
122 | @user = mock("user") |
123 | @user.stub!(:reload).and_return(@user) |
124 | @user.stub!(:login).and_return('newbob') |
125 | User.stub!(:new).and_return(@user) |
126 | User.stub!(:authenticate).and_return(@user) |
127 | @user.stub!(:save).and_return(@user) |
128 | end |
129 | |
130 | specify 'creates and saves a user' do |
131 | User.should_receive(:new).and_return(@user) |
132 | @user.should_receive(:save).and_return(@user) |
133 | post 'signup', params |
134 | assigns[:user].should == @user |
135 | end |
136 | |
137 | specify 'redirects to /admin/general' do |
138 | controller.should_redirect_to :controller => 'admin/general', :action => 'index' |
139 | post 'signup', params |
140 | end |
141 | |
142 | specify 'session gets a user' do |
143 | post 'signup', params |
144 | flash[:notice].should == 'Signup successful' |
145 | request.session[:user].should == @user |
146 | end |
147 | |
148 | specify 'Sets the flash notice to "Signup successful"' do |
149 | post 'signup', params |
150 | flash[:notice].should == 'Signup successful' |
151 | end |
152 | |
153 | def params |
154 | {'user' => {'login' => 'newbob', 'password' => 'newpassword', |
155 | 'password_confirmation' => 'newpassword'}} |
156 | end |
157 | end |
158 | |
159 | context 'User is logged in' do |
160 | controller_name :accounts |
161 | |
162 | setup do |
163 | @user = mock('user') |
164 | |
165 | session[:user] = @user |
166 | @user.stub!(:reload).and_return(@user) |
167 | request.cookies[:typoapp_is_admin] = 'yes' |
168 | end |
169 | |
170 | specify 'logging out deletes the session[:user]' do |
171 | get 'logout' |
172 | session[:user].should == nil |
173 | end |
174 | |
175 | specify 'renders the logout action' do |
176 | controller.should_render :logout |
177 | get 'logout' |
178 | end |
179 | |
180 | specify 'logging out deletes the "typoapp_is_admin" cookie' do |
181 | get 'logout' |
182 | response.cookies[:typoapp_is_admin].should_be_blank |
183 | end |
184 | end |