Mercurial > hg > soundsoftware-site
comparison test/unit/enumeration_test.rb @ 1337:077b8890835a cannam
Merge from live branch
author | Chris Cannam |
---|---|
date | Thu, 20 Jun 2013 13:14:02 +0100 |
parents | 433d4f72a19b |
children | 622f24f53b42 |
comparison
equal
deleted
inserted
replaced
1304:6137548ba453 | 1337:077b8890835a |
---|---|
1 # Redmine - project management software | 1 # Redmine - project management software |
2 # Copyright (C) 2006-2008 Jean-Philippe Lang | 2 # Copyright (C) 2006-2012 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. |
18 require File.expand_path('../../test_helper', __FILE__) | 18 require File.expand_path('../../test_helper', __FILE__) |
19 | 19 |
20 class EnumerationTest < ActiveSupport::TestCase | 20 class EnumerationTest < ActiveSupport::TestCase |
21 fixtures :enumerations, :issues, :custom_fields, :custom_values | 21 fixtures :enumerations, :issues, :custom_fields, :custom_values |
22 | 22 |
23 def setup | |
24 end | |
25 | |
26 def test_objects_count | 23 def test_objects_count |
27 # low priority | 24 # low priority |
28 assert_equal 6, Enumeration.find(4).objects_count | 25 assert_equal 6, Enumeration.find(4).objects_count |
29 # urgent | 26 # urgent |
30 assert_equal 0, Enumeration.find(7).objects_count | 27 assert_equal 0, Enumeration.find(7).objects_count |
39 | 36 |
40 def test_default | 37 def test_default |
41 e = Enumeration.default | 38 e = Enumeration.default |
42 assert e.is_a?(Enumeration) | 39 assert e.is_a?(Enumeration) |
43 assert e.is_default? | 40 assert e.is_default? |
41 assert e.active? | |
44 assert_equal 'Default Enumeration', e.name | 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? | |
45 end | 53 end |
46 | 54 |
47 def test_create | 55 def test_create |
48 e = Enumeration.new(:name => 'Not default', :is_default => false) | 56 e = Enumeration.new(:name => 'Not default', :is_default => false) |
49 e.type = 'Enumeration' | 57 e.type = 'Enumeration' |
106 | 114 |
107 # Setup as an override | 115 # Setup as an override |
108 enumeration.parent = Enumeration.find(5) | 116 enumeration.parent = Enumeration.find(5) |
109 assert enumeration.is_override? | 117 assert enumeration.is_override? |
110 end | 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 | |
111 end | 130 end |