Mercurial > hg > soundsoftware-site
comparison .svn/pristine/4f/4fc60931645e3d4832cac83cc1c9d2c25c5df098.svn-base @ 1298:4f746d8966dd redmine_2.3_integration
Merge from redmine-2.3 branch to create new branch redmine-2.3-integration
author | Chris Cannam |
---|---|
date | Fri, 14 Jun 2013 09:28:30 +0100 |
parents | 622f24f53b42 |
children |
comparison
equal
deleted
inserted
replaced
1297:0a574315af3e | 1298:4f746d8966dd |
---|---|
1 # Redmine - project management software | |
2 # Copyright (C) 2006-2013 Jean-Philippe Lang | |
3 # | |
4 # This program is free software; you can redistribute it and/or | |
5 # modify it under the terms of the GNU General Public License | |
6 # as published by the Free Software Foundation; either version 2 | |
7 # of the License, or (at your option) any later version. | |
8 # | |
9 # This program is distributed in the hope that it will be useful, | |
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 # GNU General Public License for more details. | |
13 # | |
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 | |
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
17 | |
18 require File.expand_path('../../test_helper', __FILE__) | |
19 | |
20 class EnumerationTest < ActiveSupport::TestCase | |
21 fixtures :enumerations, :issues, :custom_fields, :custom_values | |
22 | |
23 def test_objects_count | |
24 # low priority | |
25 assert_equal 6, Enumeration.find(4).objects_count | |
26 # urgent | |
27 assert_equal 0, Enumeration.find(7).objects_count | |
28 end | |
29 | |
30 def test_in_use | |
31 # low priority | |
32 assert Enumeration.find(4).in_use? | |
33 # urgent | |
34 assert !Enumeration.find(7).in_use? | |
35 end | |
36 | |
37 def test_default | |
38 e = Enumeration.default | |
39 assert e.is_a?(Enumeration) | |
40 assert e.is_default? | |
41 assert e.active? | |
42 assert_equal 'Default Enumeration', e.name | |
43 end | |
44 | |
45 def test_default_non_active | |
46 e = Enumeration.find(12) | |
47 assert e.is_a?(Enumeration) | |
48 assert e.is_default? | |
49 assert e.active? | |
50 e.update_attributes(:active => false) | |
51 assert e.is_default? | |
52 assert !e.active? | |
53 end | |
54 | |
55 def test_create | |
56 e = Enumeration.new(:name => 'Not default', :is_default => false) | |
57 e.type = 'Enumeration' | |
58 assert e.save | |
59 assert_equal 'Default Enumeration', Enumeration.default.name | |
60 end | |
61 | |
62 def test_create_as_default | |
63 e = Enumeration.new(:name => 'Very urgent', :is_default => true) | |
64 e.type = 'Enumeration' | |
65 assert e.save | |
66 assert_equal e, Enumeration.default | |
67 end | |
68 | |
69 def test_update_default | |
70 e = Enumeration.default | |
71 e.update_attributes(:name => 'Changed', :is_default => true) | |
72 assert_equal e, Enumeration.default | |
73 end | |
74 | |
75 def test_update_default_to_non_default | |
76 e = Enumeration.default | |
77 e.update_attributes(:name => 'Changed', :is_default => false) | |
78 assert_nil Enumeration.default | |
79 end | |
80 | |
81 def test_change_default | |
82 e = Enumeration.find_by_name('Default Enumeration') | |
83 e.update_attributes(:name => 'Changed Enumeration', :is_default => true) | |
84 assert_equal e, Enumeration.default | |
85 end | |
86 | |
87 def test_destroy_with_reassign | |
88 Enumeration.find(4).destroy(Enumeration.find(6)) | |
89 assert_nil Issue.where(:priority_id => 4).first | |
90 assert_equal 6, Enumeration.find(6).objects_count | |
91 end | |
92 | |
93 def test_should_be_customizable | |
94 assert Enumeration.included_modules.include?(Redmine::Acts::Customizable::InstanceMethods) | |
95 end | |
96 | |
97 def test_should_belong_to_a_project | |
98 association = Enumeration.reflect_on_association(:project) | |
99 assert association, "No Project association found" | |
100 assert_equal :belongs_to, association.macro | |
101 end | |
102 | |
103 def test_should_act_as_tree | |
104 enumeration = Enumeration.find(4) | |
105 | |
106 assert enumeration.respond_to?(:parent) | |
107 assert enumeration.respond_to?(:children) | |
108 end | |
109 | |
110 def test_is_override | |
111 # Defaults to off | |
112 enumeration = Enumeration.find(4) | |
113 assert !enumeration.is_override? | |
114 | |
115 # Setup as an override | |
116 enumeration.parent = Enumeration.find(5) | |
117 assert enumeration.is_override? | |
118 end | |
119 | |
120 def test_get_subclasses | |
121 classes = Enumeration.get_subclasses | |
122 assert_include IssuePriority, classes | |
123 assert_include DocumentCategory, classes | |
124 assert_include TimeEntryActivity, classes | |
125 | |
126 classes.each do |klass| | |
127 assert_equal Enumeration, klass.superclass | |
128 end | |
129 end | |
130 end |