Skip to content

Commit

Permalink
Fixed a bug:
Browse files Browse the repository at this point in the history
Issue description change notification: link does't work
that was in #1717 Show diff for issue description change
  • Loading branch information
Artem Vasiliev committed Dec 16, 2008
1 parent fa4d06f commit a340882
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 7 deletions.
9 changes: 7 additions & 2 deletions app/helpers/issues_helper.rb
Expand Up @@ -46,7 +46,9 @@ def sidebar_queries
@sidebar_queries
end

def show_detail(detail, no_html=false)
def show_detail(detail, options = {})
options.reverse_merge! :no_html => false, :url_options => {}
no_html = options[:no_html]
case detail.property
when 'attr'
label = l(("field_" + detail.prop_key.to_s.gsub(/\_id$/, "")).to_sym)
Expand Down Expand Up @@ -76,7 +78,10 @@ def show_detail(detail, no_html=false)
v = Version.find_by_id(detail.value) and value = v.name if detail.value
v = Version.find_by_id(detail.old_value) and old_value = v.name if detail.old_value
when 'description'
return content_tag('strong', 'Description') + ' ' + link_to('changed', :controller => 'issues', :action => 'diff', :id => detail.id)
return content_tag('strong', 'Description') + ' ' +
link_to('changed', url_for(options[:url_options].
merge(:controller => 'issues', :action => 'diff', :id => detail.id)
))

when 'estimated_hours'
value = "%0.02f" % detail.value.to_f unless detail.value.blank?
Expand Down
3 changes: 2 additions & 1 deletion app/models/mailer.rb
Expand Up @@ -48,7 +48,8 @@ def issue_edit(journal)
subject s
body :issue => issue,
:journal => journal,
:issue_url => url_for(:controller => 'issues', :action => 'show', :id => issue)
:issue_url => url_for(:controller => 'issues', :action => 'show', :id => issue),
:url_options => default_url_options
end

def reminder(user, issues, days)
Expand Down
2 changes: 1 addition & 1 deletion app/views/issues/changes.rxml
Expand Up @@ -20,7 +20,7 @@ xml.feed "xmlns" => "http://www.w3.org/2005/Atom" do
xml.content "type" => "html" do
xml.text! '<ul>'
change.details.each do |detail|
xml.text! '<li>' + show_detail(detail, false) + '</li>'
xml.text! '<li>' + show_detail(detail, :no_html => false) + '</li>'
end
xml.text! '</ul>'
xml.text! textilizable(change.notes) unless change.notes.blank?
Expand Down
2 changes: 1 addition & 1 deletion app/views/issues/show.rfpdf
Expand Up @@ -98,7 +98,7 @@
pdf.Ln
pdf.SetFontStyle('I',8)
for detail in journal.details
pdf.Cell(190,5, "- " + show_detail(detail, true))
pdf.Cell(190,5, "- " + show_detail(detail, :no_html => true))
pdf.Ln
end
if journal.notes?
Expand Down
2 changes: 1 addition & 1 deletion app/views/mailer/issue_edit.text.html.rhtml
Expand Up @@ -2,7 +2,7 @@

<ul>
<% for detail in @journal.details %>
<li><%= show_detail(detail, true) %></li>
<li><%= show_detail(detail, :no_html => true, :url_options => @url_options) %></li>
<% end %>
</ul>

Expand Down
2 changes: 1 addition & 1 deletion app/views/mailer/issue_edit.text.plain.rhtml
@@ -1,7 +1,7 @@
<%= l(:text_issue_updated, "##{@issue.id}", @journal.user) %>
<% for detail in @journal.details -%>
<%= show_detail(detail, true) %>
<%= show_detail(detail, :no_html => true, :url_options => @url_options) %>
<% end -%>
<%= @journal.notes if @journal.notes? %>
Expand Down
7 changes: 7 additions & 0 deletions test/fixtures/journal_details.yml
Expand Up @@ -13,3 +13,10 @@ journal_details_002:
value: "30"
prop_key: done_ratio
journal_id: 1
journal_details_1_description_changed:
old_value: "one"
property: attr
id: 3
value: "two"
prop_key: description
journal_id: 1
9 changes: 9 additions & 0 deletions test/unit/mailer_test.rb
Expand Up @@ -55,6 +55,15 @@ def test_issue_edit
assert Mailer.deliver_issue_edit(journal)
end
end

def test_description_changed
journal = Journal.find(1)
Setting.default_language = 'en'
msg = Mailer.create_issue_edit(journal)
assert msg.body['<strong>Description</strong>'], "there should be Description Changed note"
assert !msg.body['<a href="/issues/diff'], "no relative link to Description diff is expected"
assert msg.body['<a href="%s://%s/issues/diff' % [Setting.protocol, Setting.host_name]], "absolute link to Description diff is expected"
end

def test_document_added
document = Document.find(1)
Expand Down

0 comments on commit a340882

Please sign in to comment.