@@ -1,16 +1,16 | |||||
1 |
# |
|
1 | # Redmine - project management software | |
2 | # Copyright (C) 2006-2008 Jean-Philippe Lang |
|
2 | # Copyright (C) 2006-2008 Jean-Philippe Lang | |
3 | # |
|
3 | # | |
4 | # This program is free software; you can redistribute it and/or |
|
4 | # This program is free software; you can redistribute it and/or | |
5 | # modify it under the terms of the GNU General Public License |
|
5 | # modify it under the terms of the GNU General Public License | |
6 | # as published by the Free Software Foundation; either version 2 |
|
6 | # as published by the Free Software Foundation; either version 2 | |
7 | # of the License, or (at your option) any later version. |
|
7 | # of the License, or (at your option) any later version. | |
8 |
# |
|
8 | # | |
9 | # This program is distributed in the hope that it will be useful, |
|
9 | # This program is distributed in the hope that it will be useful, | |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. |
|
12 | # GNU General Public License for more details. | |
13 |
# |
|
13 | # | |
14 | # You should have received a copy of the GNU General Public License |
|
14 | # You should have received a copy of the GNU General Public License | |
15 | # along with this program; if not, write to the Free Software |
|
15 | # along with this program; if not, write to the Free Software | |
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
@@ -22,60 +22,60 class EnumerationTest < ActiveSupport::TestCase | |||||
22 |
|
22 | |||
23 | def setup |
|
23 | def setup | |
24 | end |
|
24 | end | |
25 |
|
25 | |||
26 | def test_objects_count |
|
26 | def test_objects_count | |
27 | # low priority |
|
27 | # low priority | |
28 | assert_equal 6, Enumeration.find(4).objects_count |
|
28 | assert_equal 6, Enumeration.find(4).objects_count | |
29 | # urgent |
|
29 | # urgent | |
30 | assert_equal 0, Enumeration.find(7).objects_count |
|
30 | assert_equal 0, Enumeration.find(7).objects_count | |
31 | end |
|
31 | end | |
32 |
|
32 | |||
33 | def test_in_use |
|
33 | def test_in_use | |
34 | # low priority |
|
34 | # low priority | |
35 | assert Enumeration.find(4).in_use? |
|
35 | assert Enumeration.find(4).in_use? | |
36 | # urgent |
|
36 | # urgent | |
37 | assert !Enumeration.find(7).in_use? |
|
37 | assert !Enumeration.find(7).in_use? | |
38 | end |
|
38 | end | |
39 |
|
39 | |||
40 | def test_default |
|
40 | def test_default | |
41 | e = Enumeration.default |
|
41 | e = Enumeration.default | |
42 | assert e.is_a?(Enumeration) |
|
42 | assert e.is_a?(Enumeration) | |
43 | assert e.is_default? |
|
43 | assert e.is_default? | |
44 | assert_equal 'Default Enumeration', e.name |
|
44 | assert_equal 'Default Enumeration', e.name | |
45 | end |
|
45 | end | |
46 |
|
46 | |||
47 | def test_create |
|
47 | def test_create | |
48 | e = Enumeration.new(:name => 'Not default', :is_default => false) |
|
48 | e = Enumeration.new(:name => 'Not default', :is_default => false) | |
49 | e.type = 'Enumeration' |
|
49 | e.type = 'Enumeration' | |
50 | assert e.save |
|
50 | assert e.save | |
51 | assert_equal 'Default Enumeration', Enumeration.default.name |
|
51 | assert_equal 'Default Enumeration', Enumeration.default.name | |
52 | end |
|
52 | end | |
53 |
|
53 | |||
54 | def test_create_as_default |
|
54 | def test_create_as_default | |
55 | e = Enumeration.new(:name => 'Very urgent', :is_default => true) |
|
55 | e = Enumeration.new(:name => 'Very urgent', :is_default => true) | |
56 | e.type = 'Enumeration' |
|
56 | e.type = 'Enumeration' | |
57 | assert e.save |
|
57 | assert e.save | |
58 | assert_equal e, Enumeration.default |
|
58 | assert_equal e, Enumeration.default | |
59 | end |
|
59 | end | |
60 |
|
60 | |||
61 | def test_update_default |
|
61 | def test_update_default | |
62 | e = Enumeration.default |
|
62 | e = Enumeration.default | |
63 | e.update_attributes(:name => 'Changed', :is_default => true) |
|
63 | e.update_attributes(:name => 'Changed', :is_default => true) | |
64 | assert_equal e, Enumeration.default |
|
64 | assert_equal e, Enumeration.default | |
65 | end |
|
65 | end | |
66 |
|
66 | |||
67 | def test_update_default_to_non_default |
|
67 | def test_update_default_to_non_default | |
68 | e = Enumeration.default |
|
68 | e = Enumeration.default | |
69 | e.update_attributes(:name => 'Changed', :is_default => false) |
|
69 | e.update_attributes(:name => 'Changed', :is_default => false) | |
70 | assert_nil Enumeration.default |
|
70 | assert_nil Enumeration.default | |
71 | end |
|
71 | end | |
72 |
|
72 | |||
73 | def test_change_default |
|
73 | def test_change_default | |
74 | e = Enumeration.find_by_name('Default Enumeration') |
|
74 | e = Enumeration.find_by_name('Default Enumeration') | |
75 | e.update_attributes(:name => 'Changed Enumeration', :is_default => true) |
|
75 | e.update_attributes(:name => 'Changed Enumeration', :is_default => true) | |
76 | assert_equal e, Enumeration.default |
|
76 | assert_equal e, Enumeration.default | |
77 | end |
|
77 | end | |
78 |
|
78 | |||
79 | def test_destroy_with_reassign |
|
79 | def test_destroy_with_reassign | |
80 | Enumeration.find(4).destroy(Enumeration.find(6)) |
|
80 | Enumeration.find(4).destroy(Enumeration.find(6)) | |
81 | assert_nil Issue.find(:first, :conditions => {:priority_id => 4}) |
|
81 | assert_nil Issue.find(:first, :conditions => {:priority_id => 4}) |
General Comments 0
You need to be logged in to leave comments.
Login now