To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.

Statistics Download as Zip
| Branch: | Tag: | Revision:

root / .svn / pristine / 06 / 068885f0c95ca2ed440e38b13dd95f7bb13f11dc.svn-base @ 912:5e80956cc792

History | View | Annotate | Download (2 KB)

1 909:cbb26bc654de Chris
# Redmine - project management software
2
# Copyright (C) 2006-2011  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 CustomFieldTest < ActiveSupport::TestCase
21
  fixtures :custom_fields
22
23
  def test_create
24
    field = UserCustomField.new(:name => 'Money money money', :field_format => 'float')
25
    assert field.save
26
  end
27
28
  def test_regexp_validation
29
    field = IssueCustomField.new(:name => 'regexp', :field_format => 'text', :regexp => '[a-z0-9')
30
    assert !field.save
31
    assert_equal I18n.t('activerecord.errors.messages.invalid'), field.errors.on(:regexp)
32
33
    field.regexp = '[a-z0-9]'
34
    assert field.save
35
  end
36
37
  def test_possible_values_should_accept_an_array
38
    field = CustomField.new
39
    field.possible_values = ["One value", ""]
40
    assert_equal ["One value"], field.possible_values
41
  end
42
43
  def test_possible_values_should_accept_a_string
44
    field = CustomField.new
45
    field.possible_values = "One value"
46
    assert_equal ["One value"], field.possible_values
47
  end
48
49
  def test_possible_values_should_accept_a_multiline_string
50
    field = CustomField.new
51
    field.possible_values = "One value\nAnd another one  \r\n \n"
52
    assert_equal ["One value", "And another one"], field.possible_values
53
  end
54
55
  def test_destroy
56
    field = CustomField.find(1)
57
    assert field.destroy
58
  end
59
end