##// END OF EJS Templates
Overrides IssueRelation#to_s....
Jean-Philippe Lang -
r13181:5326eb233e39
parent child
Show More
@@ -134,6 +134,16 class IssueRelation < ActiveRecord::Base
134 134 :unknow
135 135 end
136 136
137 def to_s(issue=nil)
138 issue ||= issue_from
139 issue_text = block_given? ? yield(other_issue(issue)) : "##{other_issue(issue).try(:id)}"
140 s = []
141 s << l(label_for(issue))
142 s << "(#{l('datetime.distance_in_words.x_days', :count => delay)})" if delay && delay != 0
143 s << issue_text
144 s.join(' ')
145 end
146
137 147 def css_classes_for(issue)
138 148 "rel-#{relation_type_for(issue)}"
139 149 end
@@ -14,10 +14,7
14 14 <tr class="issue hascontextmenu" id="relation-<%= relation.id %>">
15 15 <td class="checkbox"><%= check_box_tag("ids[]", other_issue.id, false, :id => nil) %></td>
16 16 <td class="subject">
17 <%= l(relation.label_for(@issue)) %>
18 <%= "(#{l('datetime.distance_in_words.x_days', :count => relation.delay)})" if relation.delay && relation.delay != 0 %>
19 <%= h(other_issue.project) + ' - ' if Setting.cross_project_issue_relations? %>
20 <%= link_to_issue(other_issue, :truncate => 60) %>
17 <%= relation.to_s(@issue) {|other| link_to_issue(other, :truncate => 60, :project => Setting.cross_project_issue_relations?)}.html_safe %>
21 18 </td>
22 19 <td class="status"><%=h other_issue.status.name %></td>
23 20 <td class="start_date"><%= format_date(other_issue.start_date) %></td>
@@ -214,4 +214,23 class IssueRelationTest < ActiveSupport::TestCase
214 214 assert_equal '10', to.journals.last.details.last.old_value
215 215 assert_nil to.journals.last.details.last.value
216 216 end
217
218 def test_to_s_should_return_the_relation_string
219 set_language_if_valid 'en'
220 relation = IssueRelation.find(1)
221 assert_equal "Blocks #9", relation.to_s(relation.issue_from)
222 assert_equal "Blocked by #10", relation.to_s(relation.issue_to)
223 end
224
225 def test_to_s_without_argument_should_return_the_relation_string_for_issue_from
226 set_language_if_valid 'en'
227 relation = IssueRelation.find(1)
228 assert_equal "Blocks #9", relation.to_s
229 end
230
231 def test_to_s_should_accept_a_block_as_custom_issue_formatting
232 set_language_if_valid 'en'
233 relation = IssueRelation.find(1)
234 assert_equal "Blocks Bug #9", relation.to_s {|issue| "#{issue.tracker} ##{issue.id}"}
235 end
217 236 end
General Comments 0
You need to be logged in to leave comments. Login now