Changesets can be listed by changeset number.
The Git repository is here.
- Revision:
- 98
- Log:
Initial import of Hub, an account management application.
- Author:
- adh
- Date:
- Thu Oct 19 15:18:43 +0100 2006
- Size:
- 2687 Bytes
1 | require File.dirname(__FILE__) + '/../test_helper' |
2 | |
3 | class <%= class_name %>Test < Test::Unit::TestCase |
4 | # Be sure to include AuthenticatedTestHelper in test/test_helper.rb instead. |
5 | # Then, you can remove it from this and the functional test. |
6 | include AuthenticatedTestHelper |
7 | fixtures :<%= table_name %> |
8 | |
9 | def test_should_create_<%= file_name %> |
10 | assert_difference <%= class_name %>, :count do |
11 | <%= file_name %> = create_<%= file_name %> |
12 | assert !<%= file_name %>.new_record?, "#{<%= file_name %>.errors.full_messages.to_sentence}" |
13 | end |
14 | end |
15 | |
16 | def test_should_require_login |
17 | assert_no_difference <%= class_name %>, :count do |
18 | u = create_<%= file_name %>(:login => nil) |
19 | assert u.errors.on(:login) |
20 | end |
21 | end |
22 | |
23 | def test_should_require_password |
24 | assert_no_difference <%= class_name %>, :count do |
25 | u = create_<%= file_name %>(:password => nil) |
26 | assert u.errors.on(:password) |
27 | end |
28 | end |
29 | |
30 | def test_should_require_password_confirmation |
31 | assert_no_difference <%= class_name %>, :count do |
32 | u = create_<%= file_name %>(:password_confirmation => nil) |
33 | assert u.errors.on(:password_confirmation) |
34 | end |
35 | end |
36 | |
37 | def test_should_require_email |
38 | assert_no_difference <%= class_name %>, :count do |
39 | u = create_<%= file_name %>(:email => nil) |
40 | assert u.errors.on(:email) |
41 | end |
42 | end |
43 | |
44 | def test_should_reset_password |
45 | <%= table_name %>(:quentin).update_attributes(:password => 'new password', :password_confirmation => 'new password') |
46 | assert_equal <%= table_name %>(:quentin), <%= class_name %>.authenticate('quentin', 'new password') |
47 | end |
48 | |
49 | def test_should_not_rehash_password |
50 | <%= table_name %>(:quentin).update_attributes(:login => 'quentin2') |
51 | assert_equal <%= table_name %>(:quentin), <%= class_name %>.authenticate('quentin2', 'test') |
52 | end |
53 | |
54 | def test_should_authenticate_<%= file_name %> |
55 | assert_equal <%= table_name %>(:quentin), <%= class_name %>.authenticate('quentin', 'test') |
56 | end |
57 | |
58 | def test_should_set_remember_token |
59 | <%= table_name %>(:quentin).remember_me |
60 | assert_not_nil <%= table_name %>(:quentin).remember_token |
61 | assert_not_nil <%= table_name %>(:quentin).remember_token_expires_at |
62 | end |
63 | |
64 | def test_should_unset_remember_token |
65 | <%= table_name %>(:quentin).remember_me |
66 | assert_not_nil <%= table_name %>(:quentin).remember_token |
67 | <%= table_name %>(:quentin).forget_me |
68 | assert_nil <%= table_name %>(:quentin).remember_token |
69 | end |
70 | |
71 | protected |
72 | def create_<%= file_name %>(options = {}) |
73 | <%= class_name %>.create({ :login => 'quire', :email => 'quire@example.com', :password => 'quire', :password_confirmation => 'quire' }.merge(options)) |
74 | end |
75 | end |