@@ -0,0 +1,31 | |||
|
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 | require 'redmine/field_format' | |
|
20 | ||
|
21 | class Redmine::NumericFieldFormatTest < ActionView::TestCase | |
|
22 | include ApplicationHelper | |
|
23 | ||
|
24 | def test_integer_field_with_url_pattern_should_format_as_link | |
|
25 | field = IssueCustomField.new(:field_format => 'int', :url_pattern => 'http://foo/%value%') | |
|
26 | custom_value = CustomValue.new(:custom_field => field, :customized => Issue.new, :value => "3") | |
|
27 | ||
|
28 | assert_equal 3, field.format.formatted_custom_value(self, custom_value, false) | |
|
29 | assert_equal '<a href="http://foo/3">3</a>', field.format.formatted_custom_value(self, custom_value, true) | |
|
30 | end | |
|
31 | end |
@@ -148,7 +148,7 module Redmine | |||
|
148 | 148 | |
|
149 | 149 | def formatted_value(view, custom_field, value, customized=nil, html=false) |
|
150 | 150 | casted = cast_value(custom_field, value, customized) |
|
151 | if custom_field.url_pattern.present? | |
|
151 | if html && custom_field.url_pattern.present? | |
|
152 | 152 | texts_and_urls = Array.wrap(casted).map do |single_value| |
|
153 | 153 | text = view.format_object(single_value, false).to_s |
|
154 | 154 | url = url_from_pattern(custom_field, single_value, customized) |
@@ -51,4 +51,12 class Redmine::FieldFormatTest < ActionView::TestCase | |||
|
51 | 51 | assert_equal "*foo*\nbar", field.format.formatted_custom_value(self, custom_value, false) |
|
52 | 52 | assert_include "<strong>foo</strong>", field.format.formatted_custom_value(self, custom_value, true) |
|
53 | 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 | |
|
54 | 62 | end |
General Comments 0
You need to be logged in to leave comments.
Login now