Index: lib/redmine/field_format.rb =================================================================== --- lib/redmine/field_format.rb (revision 12406) +++ lib/redmine/field_format.rb (working copy) @@ -289,6 +289,7 @@ url.gsub!('%value%') {value.to_s} url.gsub!('%id%') {customized.id.to_s} url.gsub!('%project_id%') {(customized.respond_to?(:project) ? customized.project.try(:id) : nil).to_s} + url.gsub!('%project_identifier%') {(customized.respond_to?(:project) ? customized.project.try(:identifier) : nil).to_s} if custom_field.regexp.present? url.gsub!(%r{%m(\d+)%}) do m = $1.to_i Index: test/unit/lib/redmine/field_format/link_format_test.rb =================================================================== --- test/unit/lib/redmine/field_format/link_format_test.rb (revision 12406) +++ test/unit/lib/redmine/field_format/link_format_test.rb (working copy) @@ -53,6 +53,19 @@ assert_equal 'bar', 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 'bar', field.format.formatted_custom_value(self, custom_value, true) + end + def test_link_field_should_substitue_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")