@@ -1,111 +1,111 | |||
|
1 |
# |
|
|
1 | # Redmine - project management software | |
|
2 | 2 | # Copyright (C) 2006-2008 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.expand_path('../../test_helper', __FILE__) |
|
19 | 19 | |
|
20 | 20 | class EnumerationTest < ActiveSupport::TestCase |
|
21 | 21 | fixtures :enumerations, :issues, :custom_fields, :custom_values |
|
22 | 22 | |
|
23 | 23 | def setup |
|
24 | 24 | end |
|
25 | ||
|
25 | ||
|
26 | 26 | def test_objects_count |
|
27 | 27 | # low priority |
|
28 | 28 | assert_equal 6, Enumeration.find(4).objects_count |
|
29 | 29 | # urgent |
|
30 | 30 | assert_equal 0, Enumeration.find(7).objects_count |
|
31 | 31 | end |
|
32 | ||
|
32 | ||
|
33 | 33 | def test_in_use |
|
34 | 34 | # low priority |
|
35 | 35 | assert Enumeration.find(4).in_use? |
|
36 | 36 | # urgent |
|
37 | 37 | assert !Enumeration.find(7).in_use? |
|
38 | 38 | end |
|
39 | ||
|
39 | ||
|
40 | 40 | def test_default |
|
41 | 41 | e = Enumeration.default |
|
42 | 42 | assert e.is_a?(Enumeration) |
|
43 | 43 | assert e.is_default? |
|
44 | 44 | assert_equal 'Default Enumeration', e.name |
|
45 | 45 | end |
|
46 | ||
|
46 | ||
|
47 | 47 | def test_create |
|
48 | 48 | e = Enumeration.new(:name => 'Not default', :is_default => false) |
|
49 | 49 | e.type = 'Enumeration' |
|
50 | 50 | assert e.save |
|
51 | 51 | assert_equal 'Default Enumeration', Enumeration.default.name |
|
52 | 52 | end |
|
53 | ||
|
53 | ||
|
54 | 54 | def test_create_as_default |
|
55 | 55 | e = Enumeration.new(:name => 'Very urgent', :is_default => true) |
|
56 | 56 | e.type = 'Enumeration' |
|
57 | 57 | assert e.save |
|
58 | 58 | assert_equal e, Enumeration.default |
|
59 | 59 | end |
|
60 | ||
|
60 | ||
|
61 | 61 | def test_update_default |
|
62 | 62 | e = Enumeration.default |
|
63 | 63 | e.update_attributes(:name => 'Changed', :is_default => true) |
|
64 | 64 | assert_equal e, Enumeration.default |
|
65 | 65 | end |
|
66 | ||
|
66 | ||
|
67 | 67 | def test_update_default_to_non_default |
|
68 | 68 | e = Enumeration.default |
|
69 | 69 | e.update_attributes(:name => 'Changed', :is_default => false) |
|
70 | 70 | assert_nil Enumeration.default |
|
71 | 71 | end |
|
72 | ||
|
72 | ||
|
73 | 73 | def test_change_default |
|
74 | 74 | e = Enumeration.find_by_name('Default Enumeration') |
|
75 | 75 | e.update_attributes(:name => 'Changed Enumeration', :is_default => true) |
|
76 | 76 | assert_equal e, Enumeration.default |
|
77 | 77 | end |
|
78 | ||
|
78 | ||
|
79 | 79 | def test_destroy_with_reassign |
|
80 | 80 | Enumeration.find(4).destroy(Enumeration.find(6)) |
|
81 | 81 | assert_nil Issue.find(:first, :conditions => {:priority_id => 4}) |
|
82 | 82 | assert_equal 6, Enumeration.find(6).objects_count |
|
83 | 83 | end |
|
84 | 84 | |
|
85 | 85 | def test_should_be_customizable |
|
86 | 86 | assert Enumeration.included_modules.include?(Redmine::Acts::Customizable::InstanceMethods) |
|
87 | 87 | end |
|
88 | 88 | |
|
89 | 89 | def test_should_belong_to_a_project |
|
90 | 90 | association = Enumeration.reflect_on_association(:project) |
|
91 | 91 | assert association, "No Project association found" |
|
92 | 92 | assert_equal :belongs_to, association.macro |
|
93 | 93 | end |
|
94 | 94 | |
|
95 | 95 | def test_should_act_as_tree |
|
96 | 96 | enumeration = Enumeration.find(4) |
|
97 | 97 | |
|
98 | 98 | assert enumeration.respond_to?(:parent) |
|
99 | 99 | assert enumeration.respond_to?(:children) |
|
100 | 100 | end |
|
101 | 101 | |
|
102 | 102 | def test_is_override |
|
103 | 103 | # Defaults to off |
|
104 | 104 | enumeration = Enumeration.find(4) |
|
105 | 105 | assert !enumeration.is_override? |
|
106 | 106 | |
|
107 | 107 | # Setup as an override |
|
108 | 108 | enumeration.parent = Enumeration.find(5) |
|
109 | 109 | assert enumeration.is_override? |
|
110 | 110 | end |
|
111 | 111 | end |
General Comments 0
You need to be logged in to leave comments.
Login now