summaryrefslogtreecommitdiffstats
path: root/test/unit/lib/redmine
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2013-12-15 08:53:02 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2013-12-15 08:53:02 +0000
commita4a91cab7ef70d900f35c7d0b6b41de5e1ba8ea4 (patch)
treef8f9cedf80d858f80b6e44321ee062e837306215 /test/unit/lib/redmine
parent3d36b7d91ab029ff829e2aa1484eba9201a54bfc (diff)
downloadredmine-a4a91cab7ef70d900f35c7d0b6b41de5e1ba8ea4.tar.gz
redmine-a4a91cab7ef70d900f35c7d0b6b41de5e1ba8ea4.zip
Add project identifier substitution option to the URL-pattern property of link format custom fields (#15701).
Patch by Mischa The Evil. git-svn-id: http://svn.redmine.org/redmine/trunk@12413 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/unit/lib/redmine')
-rw-r--r--test/unit/lib/redmine/field_format/link_format_test.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/test/unit/lib/redmine/field_format/link_format_test.rb b/test/unit/lib/redmine/field_format/link_format_test.rb
index 339d984aa..04f702728 100644
--- a/test/unit/lib/redmine/field_format/link_format_test.rb
+++ b/test/unit/lib/redmine/field_format/link_format_test.rb
@@ -53,6 +53,19 @@ class Redmine::LinkFieldFormatTest < ActionView::TestCase
assert_equal '<a href="http://foo/52">bar</a>', field.format.formatted_custom_value(self, custom_value, true)
end
+ def test_link_field_should_substitute_project_identifier_in_url
+ project = Project.new
+ project.stubs(:identifier).returns('foo_project-00')
+ object = Issue.new
+ object.stubs(:project).returns(project)
+
+ field = IssueCustomField.new(:field_format => 'link', :url_pattern => 'http://foo/%project_identifier%')
+ custom_value = CustomValue.new(:custom_field => field, :customized => object, :value => "bar")
+
+ assert_equal "bar", field.format.formatted_custom_value(self, custom_value, false)
+ assert_equal '<a href="http://foo/foo_project-00">bar</a>', field.format.formatted_custom_value(self, custom_value, true)
+ end
+
def test_link_field_should_substitute_regexp_groups
field = IssueCustomField.new(:field_format => 'link', :regexp => /^(.+)-(.+)$/, :url_pattern => 'http://foo/%m2%/%m1%')
custom_value = CustomValue.new(:custom_field => field, :customized => Issue.new, :value => "56-142")