Commit 68ae2d0d authored by Tim Felgentreff's avatar Tim Felgentreff

change issue specific journal query and show_details for journal helper

parent 6863c003
...@@ -103,7 +103,7 @@ class IssuesController < ApplicationController ...@@ -103,7 +103,7 @@ class IssuesController < ApplicationController
sort_update(@query.sortable_columns) sort_update(@query.sortable_columns)
if @query.valid? if @query.valid?
@journals = @query.journals(:order => "#{Journal.table_name}.created_on DESC", @journals = @query.issue_journals(:order => "#{Journal.table_name}.created_at DESC",
:limit => 25) :limit => 25)
end end
@title = (@project ? @project.name : Setting.app_title) + ": " + (@query.new_record? ? l(:label_changes_details) : @query.name) @title = (@project ? @project.name : Setting.app_title) + ": " + (@query.new_record? ? l(:label_changes_details) : @query.name)
......
...@@ -160,9 +160,8 @@ module IssuesHelper ...@@ -160,9 +160,8 @@ module IssuesHelper
export export
end end
# FIXME: This is not working as before def show_detail(journal, detail, html = true)
def show_detail(journal, html = true) journal.render_detail(detail, html)
journal.render_detail(journal.details.first, html)
end end
def gantt_zoom_link(gantt, in_or_out) def gantt_zoom_link(gantt, in_or_out)
......
...@@ -489,8 +489,8 @@ class Query < ActiveRecord::Base ...@@ -489,8 +489,8 @@ class Query < ActiveRecord::Base
# Returns the journals # Returns the journals
# Valid options are :order, :offset, :limit # Valid options are :order, :offset, :limit
def journals(options={}) def issue_journals(options={})
Journal.find :all, :include => [:user, :journaled], IssueJournal.find :all, :joins => [:user, {:issue => [:project, :author, :tracker, :status]}],
:conditions => statement, :conditions => statement,
:order => options[:order], :order => options[:order],
:limit => options[:limit], :limit => options[:limit],
......
...@@ -20,7 +20,7 @@ xml.feed "xmlns" => "http://www.w3.org/2005/Atom" do ...@@ -20,7 +20,7 @@ xml.feed "xmlns" => "http://www.w3.org/2005/Atom" do
xml.content "type" => "html" do xml.content "type" => "html" do
xml.text! '<ul>' xml.text! '<ul>'
change.details.each do |detail| change.details.each do |detail|
xml.text! '<li>' + show_detail(detail, false) + '</li>' xml.text! '<li>' + show_detail(change, detail, false) + '</li>'
end end
xml.text! '</ul>' xml.text! '</ul>'
xml.text! textilizable(change, :notes, :only_path => false) unless change.notes.blank? xml.text! textilizable(change, :notes, :only_path => false) unless change.notes.blank?
......
...@@ -286,7 +286,7 @@ module Redmine ...@@ -286,7 +286,7 @@ module Redmine
pdf.Ln pdf.Ln
pdf.SetFontStyle('I',8) pdf.SetFontStyle('I',8)
for detail in journal.details for detail in journal.details
pdf.Cell(190,5, "- " + show_detail(detail, true)) pdf.Cell(190,5, "- " + show_detail(journal, detail, true))
pdf.Ln pdf.Ln
end end
if journal.notes? if journal.notes?
......
...@@ -47,25 +47,25 @@ class IssuesHelperTest < HelperTestCase ...@@ -47,25 +47,25 @@ class IssuesHelperTest < HelperTestCase
context "IssuesHelper#show_detail" do context "IssuesHelper#show_detail" do
context "with no_html" do context "with no_html" do
should 'show a changing attribute' do should 'show a changing attribute' do
@detail = IssueJournal.generate!(:changes => {"done_ratio" => [40, 100]}, :journaled => Issue.last) @journal = IssueJournal.generate!(:changes => {"done_ratio" => [40, 100]}, :journaled => Issue.last)
assert_equal "% Done changed from 40 to 100", show_detail(@detail, true) assert_equal "% Done changed from 40 to 100", show_detail(@journal, @journal.details.to_a.first, true)
end end
should 'show a new attribute' do should 'show a new attribute' do
@detail = IssueJournal.generate!(:changes => {"done_ratio" => [nil, 100]}, :journaled => Issue.last) @journal = IssueJournal.generate!(:changes => {"done_ratio" => [nil, 100]}, :journaled => Issue.last)
assert_equal "% Done set to 100", show_detail(@detail, true) assert_equal "% Done set to 100", show_detail(@journal, @journal.details.to_a.first, true)
end end
should 'show a deleted attribute' do should 'show a deleted attribute' do
@detail = IssueJournal.generate!(:changes => {"done_ratio" => [50, nil]}, :journaled => Issue.last) @journal = IssueJournal.generate!(:changes => {"done_ratio" => [50, nil]}, :journaled => Issue.last)
assert_equal "% Done deleted (50)", show_detail(@detail, true) assert_equal "% Done deleted (50)", show_detail(@journal, @journal.details.to_a.first, true)
end end
end end
context "with html" do context "with html" do
should 'show a changing attribute with HTML highlights' do should 'show a changing attribute with HTML highlights' do
@detail = IssueJournal.generate!(:changes => {"done_ratio" => [40, 100]}, :journaled => Issue.last) @journal = IssueJournal.generate!(:changes => {"done_ratio" => [40, 100]}, :journaled => Issue.last)
@response.body = show_detail(@detail, false) @response.body = show_detail(@journal, @journal.details.to_a.first, false)
assert_select 'strong', :text => '% Done' assert_select 'strong', :text => '% Done'
assert_select 'i', :text => '40' assert_select 'i', :text => '40'
...@@ -73,16 +73,16 @@ class IssuesHelperTest < HelperTestCase ...@@ -73,16 +73,16 @@ class IssuesHelperTest < HelperTestCase
end end
should 'show a new attribute with HTML highlights' do should 'show a new attribute with HTML highlights' do
@detail = IssueJournal.generate!(:changes => {"done_ratio" => [nil, 100]}, :journaled => Issue.last) @journal = IssueJournal.generate!(:changes => {"done_ratio" => [nil, 100]}, :journaled => Issue.last)
@response.body = show_detail(@detail, false) @response.body = show_detail(@journal, @journal.details.to_a.first, false)
assert_select 'strong', :text => '% Done' assert_select 'strong', :text => '% Done'
assert_select 'i', :text => '100' assert_select 'i', :text => '100'
end end
should 'show a deleted attribute with HTML highlights' do should 'show a deleted attribute with HTML highlights' do
@detail = IssueJournal.generate!(:changes => {"done_ratio" => [50, nil]}, :journaled => Issue.last) @journal = IssueJournal.generate!(:changes => {"done_ratio" => [50, nil]}, :journaled => Issue.last)
@response.body = show_detail(@detail, false) @response.body = show_detail(@journal, @journal.details.to_a.first, false)
assert_select 'strong', :text => '% Done' assert_select 'strong', :text => '% Done'
assert_select 'strike' do assert_select 'strike' do
...@@ -93,25 +93,25 @@ class IssuesHelperTest < HelperTestCase ...@@ -93,25 +93,25 @@ class IssuesHelperTest < HelperTestCase
context "with a start_date attribute" do context "with a start_date attribute" do
should "format the current date" do should "format the current date" do
@detail = IssueJournal.generate!(:changes => {"start_date" => ['2010-01-01', '2010-01-31']}, :journaled => Issue.last) @journal = IssueJournal.generate!(:changes => {"start_date" => ['2010-01-01', '2010-01-31']}, :journaled => Issue.last)
assert_match "01/31/2010", show_detail(@detail, true) assert_match "01/31/2010", show_detail(@journal, @journal.details.to_a.first, true)
end end
should "format the old date" do should "format the old date" do
@detail = IssueJournal.generate!(:changes => {"start_date" => ['2010-01-01', '2010-01-31']}, :journaled => Issue.last) @journal = IssueJournal.generate!(:changes => {"start_date" => ['2010-01-01', '2010-01-31']}, :journaled => Issue.last)
assert_match "01/01/2010", show_detail(@detail, true) assert_match "01/01/2010", show_detail(@journal, @journal.details.to_a.first, true)
end end
end end
context "with a due_date attribute" do context "with a due_date attribute" do
should "format the current date" do should "format the current date" do
@detail = IssueJournal.generate!(:changes => {"due_date" => ['2010-01-01', '2010-01-31']}, :journaled => Issue.last) @journal = IssueJournal.generate!(:changes => {"due_date" => ['2010-01-01', '2010-01-31']}, :journaled => Issue.last)
assert_match "01/31/2010", show_detail(@detail, true) assert_match "01/31/2010", show_detail(@journal, @journal.details.to_a.first, true)
end end
should "format the old date" do should "format the old date" do
@detail = IssueJournal.generate!(:changes => {"due_date" => ['2010-01-01', '2010-01-31']}, :journaled => Issue.last) @journal = IssueJournal.generate!(:changes => {"due_date" => ['2010-01-01', '2010-01-31']}, :journaled => Issue.last)
assert_match "01/01/2010", show_detail(@detail, true) assert_match "01/01/2010", show_detail(@journal, @journal.details.to_a.first, true)
end end
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