@@ -1,16 +1,16 | |||
|
1 |
# |
|
|
2 |
# Copyright (C) 2006-20 |
|
|
1 | # Redmine - project management software | |
|
2 | # Copyright (C) 2006-2011 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. |
@@ -23,7 +23,7 class CustomValueTest < ActiveSupport::TestCase | |||
|
23 | 23 | def test_string_field_validation_with_blank_value |
|
24 | 24 | f = CustomField.new(:field_format => 'string') |
|
25 | 25 | v = CustomValue.new(:custom_field => f) |
|
26 | ||
|
26 | ||
|
27 | 27 | v.value = nil |
|
28 | 28 | assert v.valid? |
|
29 | 29 | v.value = '' |
@@ -35,7 +35,7 class CustomValueTest < ActiveSupport::TestCase | |||
|
35 | 35 | v.value = '' |
|
36 | 36 | assert !v.valid? |
|
37 | 37 | end |
|
38 | ||
|
38 | ||
|
39 | 39 | def test_string_field_validation_with_min_and_max_lengths |
|
40 | 40 | f = CustomField.new(:field_format => 'string', :min_length => 2, :max_length => 5) |
|
41 | 41 | v = CustomValue.new(:custom_field => f, :value => '') |
@@ -47,7 +47,7 class CustomValueTest < ActiveSupport::TestCase | |||
|
47 | 47 | v.value = 'a' * 6 |
|
48 | 48 | assert !v.valid? |
|
49 | 49 | end |
|
50 | ||
|
50 | ||
|
51 | 51 | def test_string_field_validation_with_regexp |
|
52 | 52 | f = CustomField.new(:field_format => 'string', :regexp => '^[A-Z0-9]*$') |
|
53 | 53 | v = CustomValue.new(:custom_field => f, :value => '') |
@@ -91,7 +91,7 class CustomValueTest < ActiveSupport::TestCase | |||
|
91 | 91 | v.value = '-123' |
|
92 | 92 | assert v.valid? |
|
93 | 93 | end |
|
94 | ||
|
94 | ||
|
95 | 95 | def test_float_field_validation |
|
96 | 96 | v = CustomValue.new(:customized => User.find(:first), :custom_field => UserCustomField.find_by_name('Money')) |
|
97 | 97 | v.value = '11.2' |
@@ -103,18 +103,18 class CustomValueTest < ActiveSupport::TestCase | |||
|
103 | 103 | v.value = '6a' |
|
104 | 104 | assert !v.save |
|
105 | 105 | end |
|
106 | ||
|
106 | ||
|
107 | 107 | def test_default_value |
|
108 | 108 | field = CustomField.find_by_default_value('Default string') |
|
109 | 109 | assert_not_nil field |
|
110 | ||
|
110 | ||
|
111 | 111 | v = CustomValue.new(:custom_field => field) |
|
112 | 112 | assert_equal 'Default string', v.value |
|
113 | 113 | |
|
114 | 114 | v = CustomValue.new(:custom_field => field, :value => 'Not empty') |
|
115 | 115 | assert_equal 'Not empty', v.value |
|
116 | 116 | end |
|
117 | ||
|
117 | ||
|
118 | 118 | def test_sti_polymorphic_association |
|
119 | 119 | # Rails uses top level sti class for polymorphic association. See #3978. |
|
120 | 120 | assert !User.find(4).custom_values.empty? |
General Comments 0
You need to be logged in to leave comments.
Login now