@@ -1,55 +1,54 | |||
|
1 | 1 | # Redmine - project management software |
|
2 | 2 | # Copyright (C) 2006-2013 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. |
|
17 | 17 | |
|
18 | 18 | require File.expand_path('../../../../../test_helper', __FILE__) |
|
19 | require 'redmine/field_format' | |
|
20 | 19 | |
|
21 | 20 | class Redmine::FieldFormatTest < ActionView::TestCase |
|
22 | 21 | include ApplicationHelper |
|
23 | 22 | |
|
24 | 23 | def test_string_field_with_text_formatting_disabled_should_not_format_text |
|
25 | 24 | field = IssueCustomField.new(:field_format => 'string') |
|
26 | 25 | custom_value = CustomValue.new(:custom_field => field, :customized => Issue.new, :value => "*foo*") |
|
27 | 26 | |
|
28 | 27 | assert_equal "*foo*", field.format.formatted_custom_value(self, custom_value, false) |
|
29 | 28 | assert_equal "*foo*", field.format.formatted_custom_value(self, custom_value, true) |
|
30 | 29 | end |
|
31 | 30 | |
|
32 | 31 | def test_string_field_with_text_formatting_enabled_should_format_text |
|
33 | 32 | field = IssueCustomField.new(:field_format => 'string', :text_formatting => 'full') |
|
34 | 33 | custom_value = CustomValue.new(:custom_field => field, :customized => Issue.new, :value => "*foo*") |
|
35 | 34 | |
|
36 | 35 | assert_equal "*foo*", field.format.formatted_custom_value(self, custom_value, false) |
|
37 | 36 | assert_include "<strong>foo</strong>", field.format.formatted_custom_value(self, custom_value, true) |
|
38 | 37 | end |
|
39 | 38 | |
|
40 | 39 | def test_text_field_with_text_formatting_disabled_should_not_format_text |
|
41 | 40 | field = IssueCustomField.new(:field_format => 'text') |
|
42 | 41 | custom_value = CustomValue.new(:custom_field => field, :customized => Issue.new, :value => "*foo*\nbar") |
|
43 | 42 | |
|
44 | 43 | assert_equal "*foo*\nbar", field.format.formatted_custom_value(self, custom_value, false) |
|
45 | 44 | assert_include "*foo*\n<br />bar", field.format.formatted_custom_value(self, custom_value, true) |
|
46 | 45 | end |
|
47 | 46 | |
|
48 | 47 | def test_text_field_with_text_formatting_enabled_should_format_text |
|
49 | 48 | field = IssueCustomField.new(:field_format => 'text', :text_formatting => 'full') |
|
50 | 49 | custom_value = CustomValue.new(:custom_field => field, :customized => Issue.new, :value => "*foo*\nbar") |
|
51 | 50 | |
|
52 | 51 | assert_equal "*foo*\nbar", field.format.formatted_custom_value(self, custom_value, false) |
|
53 | 52 | assert_include "<strong>foo</strong>", field.format.formatted_custom_value(self, custom_value, true) |
|
54 | 53 | end |
|
55 | 54 | end |
General Comments 0
You need to be logged in to leave comments.
Login now