@@ -161,33 +161,26 class AccountControllerTest < ActionController::TestCase | |||
|
161 | 161 | assert_nil @request.session[:user_id] |
|
162 | 162 | end |
|
163 | 163 | |
|
164 | context "GET #register" do | |
|
165 |
|
|
|
166 | setup do | |
|
167 | Setting.self_registration = '3' | |
|
168 | get :register | |
|
169 | end | |
|
170 | ||
|
171 | should_respond_with :success | |
|
172 | should_render_template :register | |
|
173 | should_assign_to :user | |
|
164 | def test_get_register_with_registration_on | |
|
165 | with_settings :self_registration => '3' do | |
|
166 | get :register | |
|
167 | assert_response :success | |
|
168 | assert_template 'register' | |
|
169 | assert_not_nil assigns(:user) | |
|
174 | 170 | end |
|
171 | end | |
|
175 | 172 | |
|
176 | context "with self registration off" do | |
|
177 | setup do | |
|
178 | Setting.self_registration = '0' | |
|
179 | get :register | |
|
180 | end | |
|
181 | ||
|
182 | should_redirect_to('/') { home_url } | |
|
173 | def test_get_register_with_registration_off_should_redirect | |
|
174 | with_settings :self_registration => '0' do | |
|
175 | get :register | |
|
176 | assert_redirected_to '/' | |
|
183 | 177 | end |
|
184 | 178 | end |
|
185 | 179 | |
|
186 | 180 | # See integration/account_test.rb for the full test |
|
187 | context "POST #register" do | |
|
188 |
|
|
|
189 | setup do | |
|
190 | Setting.self_registration = '3' | |
|
181 | def test_post_register_with_registration_on | |
|
182 | with_settings :self_registration => '3' do | |
|
183 | assert_difference 'User.count' do | |
|
191 | 184 | post :register, :user => { |
|
192 | 185 | :login => 'register', |
|
193 | 186 | :password => 'test', |
@@ -196,28 +189,27 class AccountControllerTest < ActionController::TestCase | |||
|
196 | 189 | :lastname => 'Doe', |
|
197 | 190 | :mail => 'register@example.com' |
|
198 | 191 | } |
|
192 | assert_redirected_to '/my/account' | |
|
199 | 193 | end |
|
200 | ||
|
201 | should_respond_with :redirect | |
|
202 | should_assign_to :user | |
|
203 | should_redirect_to('my page') { {:controller => 'my', :action => 'account'} } | |
|
204 | ||
|
205 | should_create_a_new_user { User.last(:conditions => {:login => 'register'}) } | |
|
206 | ||
|
207 | should 'set the user status to active' do | |
|
208 | user = User.last(:conditions => {:login => 'register'}) | |
|
209 | assert user | |
|
210 | assert_equal User::STATUS_ACTIVE, user.status | |
|
211 | end | |
|
194 | user = User.first(:order => 'id DESC') | |
|
195 | assert_equal 'register', user.login | |
|
196 | assert user.active? | |
|
212 | 197 | end |
|
213 | ||
|
214 | context "with self registration off" do | |
|
215 | setup do | |
|
216 |
|
|
|
217 | post :register | |
|
198 | end | |
|
199 | ||
|
200 | def test_post_register_with_registration_off_should_redirect | |
|
201 | with_settings :self_registration => '0' do | |
|
202 | assert_no_difference 'User.count' do | |
|
203 | post :register, :user => { | |
|
204 | :login => 'register', | |
|
205 | :password => 'test', | |
|
206 | :password_confirmation => 'test', | |
|
207 | :firstname => 'John', | |
|
208 | :lastname => 'Doe', | |
|
209 | :mail => 'register@example.com' | |
|
210 | } | |
|
211 | assert_redirected_to '/' | |
|
218 | 212 | end |
|
219 | ||
|
220 | should_redirect_to('/') { home_url } | |
|
221 | 213 | end |
|
222 | 214 | end |
|
223 | 215 | end |
@@ -207,15 +207,6 class ActiveSupport::TestCase | |||
|
207 | 207 | end |
|
208 | 208 | end |
|
209 | 209 | |
|
210 | def self.should_create_a_new_user(&block) | |
|
211 | should "create a new user" do | |
|
212 | user = instance_eval &block | |
|
213 | assert user | |
|
214 | assert_kind_of User, user | |
|
215 | assert !user.new_record? | |
|
216 | end | |
|
217 | end | |
|
218 | ||
|
219 | 210 | # Test that a request allows the three types of API authentication |
|
220 | 211 | # |
|
221 | 212 | # * HTTP Basic with username and password |
General Comments 0
You need to be logged in to leave comments.
Login now