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:
- 3031 Bytes
1 | require File.dirname(__FILE__) + '/../test_helper' |
2 | |
3 | class UserTest < Test::Unit::TestCase |
4 | |
5 | fixtures :users, :contents |
6 | |
7 | def test_auth |
8 | assert_equal users(:bob), User.authenticate("bob", "test") |
9 | assert_nil User.authenticate("nonbob", "test") |
10 | end |
11 | |
12 | def test_articles_link |
13 | assert_equal 8, User.find(1).articles.size |
14 | assert_equal 7, User.find(1).articles.find_published.size |
15 | assert_equal 7, User.find(1).articles.published.size |
16 | |
17 | articles = User.find(1).articles.published |
18 | assert_equal articles.sort_by { |a| a.created_at }.reverse, articles |
19 | |
20 | articles = User.find(1).articles |
21 | assert_equal articles.sort_by { |a| a.created_at }.reverse, articles |
22 | end |
23 | |
24 | def test_authenticate? |
25 | assert User.authenticate?("bob", "test") |
26 | assert !User.authenticate?("bob", "wrong password") |
27 | assert User.authenticate?("tobi", "whatever") |
28 | assert !User.authenticate?("tobi", "not whatever") |
29 | end |
30 | |
31 | def test_disallowed_passwords |
32 | u = User.new |
33 | u.login = "nonbob" |
34 | |
35 | u.password = u.password_confirmation = "tiny" |
36 | assert !u.save |
37 | assert u.errors.invalid?('password') |
38 | |
39 | u.password = u.password_confirmation = "hugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehuge" |
40 | assert !u.save |
41 | assert u.errors.invalid?('password') |
42 | |
43 | u.password = u.password_confirmation = "" |
44 | assert !u.save |
45 | assert u.errors.invalid?('password') |
46 | |
47 | u.password = u.password_confirmation = "bobs_secure_password" |
48 | assert u.save |
49 | assert u.errors.empty? |
50 | |
51 | end |
52 | |
53 | def test_bad_logins |
54 | u = User.new |
55 | u.password = u.password_confirmation = "bobs_secure_password" |
56 | |
57 | u.login = "x" |
58 | assert !u.save |
59 | assert u.errors.invalid?('login') |
60 | |
61 | u.login = "hugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhug" |
62 | assert !u.save |
63 | assert u.errors.invalid?('login') |
64 | |
65 | u.login = "" |
66 | assert !u.save |
67 | assert u.errors.invalid?('login') |
68 | |
69 | u.login = "okbob" |
70 | assert u.save |
71 | assert u.errors.empty? |
72 | |
73 | end |
74 | |
75 | def test_change_name |
76 | u = User.new |
77 | u.password = u.password_confirmation = "a_password" |
78 | u.login = 'xxx' |
79 | assert u.save |
80 | |
81 | u.password = u.password_confirmation = '' |
82 | u.name = 'X X X' |
83 | u.email = 'x@example.com' |
84 | assert u.save |
85 | end |
86 | |
87 | def test_collision |
88 | u = User.new |
89 | u.login = "existingbob" |
90 | u.password = u.password_confirmation = "bobs_secure_password" |
91 | assert !u.save |
92 | end |
93 | |
94 | |
95 | def test_create |
96 | u = User.new |
97 | u.login = "nonexistingbob" |
98 | u.password = u.password_confirmation = "bobs_secure_password" |
99 | |
100 | assert u.save |
101 | end |
102 | |
103 | def test_sha1 |
104 | u = User.new |
105 | u.login = "nonexistingbob" |
106 | u.password = u.password_confirmation = "bobs_secure_password" |
107 | assert u.save |
108 | |
109 | assert_equal '98740ff87bade6d895010bceebbd9f718e7856bb', u.password |
110 | end |
111 | end |