comparison .svn/pristine/dd/dd9134549337665f524bdb47a703c3f0965bb6d6.svn-base @ 1517:dffacf8a6908 redmine-2.5

Update to Redmine SVN revision 13367 on 2.5-stable branch
author Chris Cannam
date Tue, 09 Sep 2014 09:29:00 +0100
parents
children
comparison
equal deleted inserted replaced
1516:b450a9d58aed 1517:dffacf8a6908
1 # Redmine - project management software
2 # Copyright (C) 2006-2014 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 Redmine::FieldFormatTest < ActionView::TestCase
21 include ApplicationHelper
22
23 def test_string_field_with_text_formatting_disabled_should_not_format_text
24 field = IssueCustomField.new(:field_format => 'string')
25 custom_value = CustomValue.new(:custom_field => field, :customized => Issue.new, :value => "*foo*")
26
27 assert_equal "*foo*", field.format.formatted_custom_value(self, custom_value, false)
28 assert_equal "*foo*", field.format.formatted_custom_value(self, custom_value, true)
29 end
30
31 def test_string_field_with_text_formatting_enabled_should_format_text
32 field = IssueCustomField.new(:field_format => 'string', :text_formatting => 'full')
33 custom_value = CustomValue.new(:custom_field => field, :customized => Issue.new, :value => "*foo*")
34
35 assert_equal "*foo*", field.format.formatted_custom_value(self, custom_value, false)
36 assert_include "<strong>foo</strong>", field.format.formatted_custom_value(self, custom_value, true)
37 end
38
39 def test_text_field_with_text_formatting_disabled_should_not_format_text
40 field = IssueCustomField.new(:field_format => 'text')
41 custom_value = CustomValue.new(:custom_field => field, :customized => Issue.new, :value => "*foo*\nbar")
42
43 assert_equal "*foo*\nbar", field.format.formatted_custom_value(self, custom_value, false)
44 assert_include "*foo*\n<br />bar", field.format.formatted_custom_value(self, custom_value, true)
45 end
46
47 def test_text_field_with_text_formatting_enabled_should_format_text
48 field = IssueCustomField.new(:field_format => 'text', :text_formatting => 'full')
49 custom_value = CustomValue.new(:custom_field => field, :customized => Issue.new, :value => "*foo*\nbar")
50
51 assert_equal "*foo*\nbar", field.format.formatted_custom_value(self, custom_value, false)
52 assert_include "<strong>foo</strong>", field.format.formatted_custom_value(self, custom_value, true)
53 end
54
55 def test_text_field_with_url_pattern_should_format_as_link
56 field = IssueCustomField.new(:field_format => 'string', :url_pattern => 'http://foo/%value%')
57 custom_value = CustomValue.new(:custom_field => field, :customized => Issue.new, :value => "bar")
58
59 assert_equal "bar", field.format.formatted_custom_value(self, custom_value, false)
60 assert_equal '<a href="http://foo/bar">bar</a>', field.format.formatted_custom_value(self, custom_value, true)
61 end
62 end