Commit 492cd561 authored by jplang's avatar jplang

Overrides IssueRelation#to_s.

git-svn-id: https://svn.redmine.org/redmine/trunk@13563 e93f8b46-1217-0410-a6f0-8f06a7374b81
parent 57a5e9ed
......@@ -134,6 +134,16 @@ class IssueRelation < ActiveRecord::Base
:unknow
end
def to_s(issue=nil)
issue ||= issue_from
issue_text = block_given? ? yield(other_issue(issue)) : "##{other_issue(issue).try(:id)}"
s = []
s << l(label_for(issue))
s << "(#{l('datetime.distance_in_words.x_days', :count => delay)})" if delay && delay != 0
s << issue_text
s.join(' ')
end
def css_classes_for(issue)
"rel-#{relation_type_for(issue)}"
end
......
......@@ -14,10 +14,7 @@
<tr class="issue hascontextmenu" id="relation-<%= relation.id %>">
<td class="checkbox"><%= check_box_tag("ids[]", other_issue.id, false, :id => nil) %></td>
<td class="subject">
<%= l(relation.label_for(@issue)) %>
<%= "(#{l('datetime.distance_in_words.x_days', :count => relation.delay)})" if relation.delay && relation.delay != 0 %>
<%= h(other_issue.project) + ' - ' if Setting.cross_project_issue_relations? %>
<%= link_to_issue(other_issue, :truncate => 60) %>
<%= relation.to_s(@issue) {|other| link_to_issue(other, :truncate => 60, :project => Setting.cross_project_issue_relations?)}.html_safe %>
</td>
<td class="status"><%=h other_issue.status.name %></td>
<td class="start_date"><%= format_date(other_issue.start_date) %></td>
......
......@@ -214,4 +214,23 @@ class IssueRelationTest < ActiveSupport::TestCase
assert_equal '10', to.journals.last.details.last.old_value
assert_nil to.journals.last.details.last.value
end
def test_to_s_should_return_the_relation_string
set_language_if_valid 'en'
relation = IssueRelation.find(1)
assert_equal "Blocks #9", relation.to_s(relation.issue_from)
assert_equal "Blocked by #10", relation.to_s(relation.issue_to)
end
def test_to_s_without_argument_should_return_the_relation_string_for_issue_from
set_language_if_valid 'en'
relation = IssueRelation.find(1)
assert_equal "Blocks #9", relation.to_s
end
def test_to_s_should_accept_a_block_as_custom_issue_formatting
set_language_if_valid 'en'
relation = IssueRelation.find(1)
assert_equal "Blocks Bug #9", relation.to_s {|issue| "#{issue.tracker} ##{issue.id}"}
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment