@@ -5,12 +5,12 | |||||
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. | |
@@ -19,39 +19,39 require File.expand_path('../../test_helper', __FILE__) | |||||
19 |
|
19 | |||
20 | class CustomFieldTest < ActiveSupport::TestCase |
|
20 | class CustomFieldTest < ActiveSupport::TestCase | |
21 | fixtures :custom_fields |
|
21 | fixtures :custom_fields | |
22 |
|
22 | |||
23 | def test_create |
|
23 | def test_create | |
24 | field = UserCustomField.new(:name => 'Money money money', :field_format => 'float') |
|
24 | field = UserCustomField.new(:name => 'Money money money', :field_format => 'float') | |
25 | assert field.save |
|
25 | assert field.save | |
26 | end |
|
26 | end | |
27 |
|
27 | |||
28 | def test_regexp_validation |
|
28 | def test_regexp_validation | |
29 | field = IssueCustomField.new(:name => 'regexp', :field_format => 'text', :regexp => '[a-z0-9') |
|
29 | field = IssueCustomField.new(:name => 'regexp', :field_format => 'text', :regexp => '[a-z0-9') | |
30 | assert !field.save |
|
30 | assert !field.save | |
31 | assert_equal I18n.t('activerecord.errors.messages.invalid'), field.errors.on(:regexp) |
|
31 | assert_equal I18n.t('activerecord.errors.messages.invalid'), field.errors.on(:regexp) | |
32 |
|
32 | |||
33 | field.regexp = '[a-z0-9]' |
|
33 | field.regexp = '[a-z0-9]' | |
34 | assert field.save |
|
34 | assert field.save | |
35 | end |
|
35 | end | |
36 |
|
36 | |||
37 | def test_possible_values_should_accept_an_array |
|
37 | def test_possible_values_should_accept_an_array | |
38 | field = CustomField.new |
|
38 | field = CustomField.new | |
39 | field.possible_values = ["One value", ""] |
|
39 | field.possible_values = ["One value", ""] | |
40 | assert_equal ["One value"], field.possible_values |
|
40 | assert_equal ["One value"], field.possible_values | |
41 | end |
|
41 | end | |
42 |
|
42 | |||
43 | def test_possible_values_should_accept_a_string |
|
43 | def test_possible_values_should_accept_a_string | |
44 | field = CustomField.new |
|
44 | field = CustomField.new | |
45 | field.possible_values = "One value" |
|
45 | field.possible_values = "One value" | |
46 | assert_equal ["One value"], field.possible_values |
|
46 | assert_equal ["One value"], field.possible_values | |
47 | end |
|
47 | end | |
48 |
|
48 | |||
49 | def test_possible_values_should_accept_a_multiline_string |
|
49 | def test_possible_values_should_accept_a_multiline_string | |
50 | field = CustomField.new |
|
50 | field = CustomField.new | |
51 | field.possible_values = "One value\nAnd another one \r\n \n" |
|
51 | field.possible_values = "One value\nAnd another one \r\n \n" | |
52 | assert_equal ["One value", "And another one"], field.possible_values |
|
52 | assert_equal ["One value", "And another one"], field.possible_values | |
53 | end |
|
53 | end | |
54 |
|
54 | |||
55 | def test_destroy |
|
55 | def test_destroy | |
56 | field = CustomField.find(1) |
|
56 | field = CustomField.find(1) | |
57 | assert field.destroy |
|
57 | assert field.destroy |
General Comments 0
You need to be logged in to leave comments.
Login now