: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
<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>
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