changelog shortlog tags changeset manifest revisions annotate raw

test/functional/users_controller_test.rb

changeset 7: ac1024130232
author: moriq@moriq.com
date: Wed Mar 05 03:57:54 2008 +0900 (16 years ago)
permissions: -rw-r--r--
description: generate authenticated again.
mercurial import したときに db/migrate lib が消えてた。orz
1require File.dirname(__FILE__) + '/../test_helper'
2require 'users_controller'
3
4# Re-raise errors caught by the controller.
5class UsersController; def rescue_action(e) raise e end; end
6
7class UsersControllerTest < Test::Unit::TestCase
8 # Be sure to include AuthenticatedTestHelper in test/test_helper.rb instead
9 # Then, you can remove it from this and the units test.
10 include AuthenticatedTestHelper
11
12 fixtures :users
13
14 def setup
15 @controller = UsersController.new
16 @request = ActionController::TestRequest.new
17 @response = ActionController::TestResponse.new
18 end
19
20 def test_should_allow_signup
21 assert_difference 'User.count' do
22 create_user
23 assert_response :redirect
24 end
25 end
26
27 def test_should_require_login_on_signup
28 assert_no_difference 'User.count' do
29 create_user(:login => nil)
30 assert assigns(:user).errors.on(:login)
31 assert_response :success
32 end
33 end
34
35 def test_should_require_password_on_signup
36 assert_no_difference 'User.count' do
37 create_user(:password => nil)
38 assert assigns(:user).errors.on(:password)
39 assert_response :success
40 end
41 end
42
43 def test_should_require_password_confirmation_on_signup
44 assert_no_difference 'User.count' do
45 create_user(:password_confirmation => nil)
46 assert assigns(:user).errors.on(:password_confirmation)
47 assert_response :success
48 end
49 end
50
51 def test_should_require_email_on_signup
52 assert_no_difference 'User.count' do
53 create_user(:email => nil)
54 assert assigns(:user).errors.on(:email)
55 assert_response :success
56 end
57 end
58
59
60 protected
61 def create_user(options = {})
62 post :create, :user => { :login => 'quire', :email => 'quire@example.com',
63 :password => 'quire', :password_confirmation => 'quire' }.merge(options)
64 end
65end