@@ -1,79 +1,79 | |||
|
1 | 1 | # redMine - project management software |
|
2 | 2 | # Copyright (C) 2006 Jean-Philippe Lang |
|
3 | 3 | # |
|
4 | 4 | # This program is free software; you can redistribute it and/or |
|
5 | 5 | # modify it under the terms of the GNU General Public License |
|
6 | 6 | # as published by the Free Software Foundation; either version 2 |
|
7 | 7 | # of the License, or (at your option) any later version. |
|
8 | 8 | # |
|
9 | 9 | # This program is distributed in the hope that it will be useful, |
|
10 | 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | 12 | # GNU General Public License for more details. |
|
13 | 13 | # |
|
14 | 14 | # You should have received a copy of the GNU General Public License |
|
15 | 15 | # along with this program; if not, write to the Free Software |
|
16 | 16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
17 | 17 | |
|
18 | 18 | require File.dirname(__FILE__) + '/../test_helper' |
|
19 | 19 | |
|
20 | 20 | class ProjectTest < Test::Unit::TestCase |
|
21 | 21 | fixtures :projects |
|
22 | 22 | |
|
23 | 23 | def setup |
|
24 | 24 | @ecookbook = Project.find(1) |
|
25 | 25 | @ecookbook_sub1 = Project.find(3) |
|
26 | 26 | end |
|
27 | 27 | |
|
28 | 28 | def test_truth |
|
29 | 29 | assert_kind_of Project, @ecookbook |
|
30 | 30 | assert_equal "eCookbook", @ecookbook.name |
|
31 | 31 | end |
|
32 | 32 | |
|
33 | 33 | def test_update |
|
34 | 34 | assert_equal "eCookbook", @ecookbook.name |
|
35 | 35 | @ecookbook.name = "eCook" |
|
36 | 36 | assert @ecookbook.save, @ecookbook.errors.full_messages.join("; ") |
|
37 | 37 | @ecookbook.reload |
|
38 | 38 | assert_equal "eCook", @ecookbook.name |
|
39 | 39 | end |
|
40 | 40 | |
|
41 | 41 | def test_validate |
|
42 | 42 | @ecookbook.name = "" |
|
43 | 43 | assert !@ecookbook.save |
|
44 | 44 | assert_equal 1, @ecookbook.errors.count |
|
45 | 45 | assert_equal "activerecord_error_blank", @ecookbook.errors.on(:name) |
|
46 | 46 | end |
|
47 | 47 | |
|
48 | 48 | def test_public_projects |
|
49 | 49 | public_projects = Project.find(:all, :conditions => ["is_public=?", true]) |
|
50 | 50 | assert_equal 3, public_projects.length |
|
51 | 51 | assert_equal true, public_projects[0].is_public? |
|
52 | 52 | end |
|
53 | 53 | |
|
54 | 54 | def test_destroy |
|
55 | 55 | @ecookbook.destroy |
|
56 | 56 | assert_raise(ActiveRecord::RecordNotFound) { Project.find(@ecookbook.id) } |
|
57 | 57 | end |
|
58 | 58 | |
|
59 | 59 | def test_subproject_ok |
|
60 | 60 | sub = Project.find(2) |
|
61 | 61 | sub.parent = @ecookbook |
|
62 | 62 | assert sub.save |
|
63 | 63 | assert_equal @ecookbook.id, sub.parent.id |
|
64 | 64 | @ecookbook.reload |
|
65 |
assert_equal 3, @ecookbook. |
|
|
65 | assert_equal 3, @ecookbook.children.size | |
|
66 | 66 | end |
|
67 | 67 | |
|
68 | 68 | def test_subproject_invalid |
|
69 | 69 | sub = Project.find(2) |
|
70 | 70 | sub.parent = @ecookbook_sub1 |
|
71 | 71 | assert !sub.save |
|
72 | 72 | end |
|
73 | 73 | |
|
74 | 74 | def test_subproject_invalid_2 |
|
75 | 75 | sub = @ecookbook |
|
76 | 76 | sub.parent = Project.find(2) |
|
77 | 77 | assert !sub.save |
|
78 | 78 | end |
|
79 | 79 | end |
General Comments 0
You need to be logged in to leave comments.
Login now