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