summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2008-05-25 13:26:21 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2008-05-25 13:26:21 +0000
commita92749ef93bbcc4e9a1116bd58d750de3054f78a (patch)
treee42bd285b71f477904b3813a5cb872c216a6c7d9
parent03f0236a6ee995363c54f958d66a0abbf0d3a827 (diff)
downloadredmine-a92749ef93bbcc4e9a1116bd58d750de3054f78a.tar.gz
redmine-a92749ef93bbcc4e9a1116bd58d750de3054f78a.zip
Gantt chart: display issues that don't have a due date if they are assigned to a version with a date (#184).
git-svn-id: http://redmine.rubyforge.org/svn/trunk@1455 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r--app/controllers/projects_controller.rb7
-rw-r--r--app/models/issue.rb6
-rw-r--r--app/views/projects/gantt.rfpdf4
-rw-r--r--app/views/projects/gantt.rhtml4
-rw-r--r--test/fixtures/issues.yml6
-rw-r--r--test/fixtures/versions.yml2
-rw-r--r--test/functional/projects_controller_test.rb11
-rw-r--r--test/functional/versions_controller_test.rb6
8 files changed, 36 insertions, 10 deletions
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb
index 34ce734a5..07b29fa25 100644
--- a/app/controllers/projects_controller.rb
+++ b/app/controllers/projects_controller.rb
@@ -382,11 +382,18 @@ class ProjectsController < ApplicationController
@events = []
@project.issues_with_subprojects(@with_subprojects) do
+ # Issues that have start and due dates
@events += Issue.find(:all,
:order => "start_date, due_date",
:include => [:tracker, :status, :assigned_to, :priority, :project],
:conditions => ["(((start_date>=? and start_date<=?) or (due_date>=? and due_date<=?) or (start_date<? and due_date>?)) and start_date is not null and due_date is not null and #{Issue.table_name}.tracker_id in (#{@selected_tracker_ids.join(',')}))", @date_from, @date_to, @date_from, @date_to, @date_from, @date_to]
) unless @selected_tracker_ids.empty?
+ # Issues that don't have a due date but that are assigned to a version with a date
+ @events += Issue.find(:all,
+ :order => "start_date, effective_date",
+ :include => [:tracker, :status, :assigned_to, :priority, :project, :fixed_version],
+ :conditions => ["(((start_date>=? and start_date<=?) or (effective_date>=? and effective_date<=?) or (start_date<? and effective_date>?)) and start_date is not null and due_date is null and effective_date is not null and #{Issue.table_name}.tracker_id in (#{@selected_tracker_ids.join(',')}))", @date_from, @date_to, @date_from, @date_to, @date_from, @date_to]
+ ) unless @selected_tracker_ids.empty?
@events += Version.find(:all, :include => :project,
:conditions => ["effective_date BETWEEN ? AND ?", @date_from, @date_to])
end
diff --git a/app/models/issue.rb b/app/models/issue.rb
index 0618b0f0a..633253db7 100644
--- a/app/models/issue.rb
+++ b/app/models/issue.rb
@@ -230,6 +230,12 @@ class Issue < ActiveRecord::Base
relations.select {|r| r.relation_type == IssueRelation::TYPE_DUPLICATES}.collect {|r| r.other_issue(self)}
end
+ # Returns the due date or the target due date if any
+ # Used on gantt chart
+ def due_before
+ due_date || (fixed_version ? fixed_version.effective_date : nil)
+ end
+
def duration
(start_date && due_date) ? due_date - start_date : 0
end
diff --git a/app/views/projects/gantt.rfpdf b/app/views/projects/gantt.rfpdf
index a293906ba..e94fc5814 100644
--- a/app/views/projects/gantt.rfpdf
+++ b/app/views/projects/gantt.rfpdf
@@ -124,9 +124,9 @@ pdf.SetFontStyle('B',7)
if i.is_a? Issue
i_start_date = (i.start_date >= @date_from ? i.start_date : @date_from )
- i_end_date = (i.due_date <= @date_to ? i.due_date : @date_to )
+ i_end_date = (i.due_before <= @date_to ? i.due_before : @date_to )
- i_done_date = i.start_date + ((i.due_date - i.start_date+1)*i.done_ratio/100).floor
+ i_done_date = i.start_date + ((i.due_before - i.start_date+1)*i.done_ratio/100).floor
i_done_date = (i_done_date <= @date_from ? @date_from : i_done_date )
i_done_date = (i_done_date >= @date_to ? @date_to : i_done_date )
diff --git a/app/views/projects/gantt.rhtml b/app/views/projects/gantt.rhtml
index f398bace7..071e0f324 100644
--- a/app/views/projects/gantt.rhtml
+++ b/app/views/projects/gantt.rhtml
@@ -166,9 +166,9 @@ top = headers_height + 10
@events.each do |i|
if i.is_a? Issue
i_start_date = (i.start_date >= @date_from ? i.start_date : @date_from )
- i_end_date = (i.due_date <= @date_to ? i.due_date : @date_to )
+ i_end_date = (i.due_before <= @date_to ? i.due_before : @date_to )
- i_done_date = i.start_date + ((i.due_date - i.start_date+1)*i.done_ratio/100).floor
+ i_done_date = i.start_date + ((i.due_before - i.start_date+1)*i.done_ratio/100).floor
i_done_date = (i_done_date <= @date_from ? @date_from : i_done_date )
i_done_date = (i_done_date >= @date_to ? @date_to : i_done_date )
diff --git a/test/fixtures/issues.yml b/test/fixtures/issues.yml
index 48195a7b7..c037624ae 100644
--- a/test/fixtures/issues.yml
+++ b/test/fixtures/issues.yml
@@ -13,6 +13,8 @@ issues_001:
assigned_to_id:
author_id: 2
status_id: 1
+ start_date: <%= 1.day.ago.to_date.to_s(:db) %>
+ due_date: <%= 10.day.from_now.to_date.to_s(:db) %>
issues_002:
created_on: 2006-07-19 21:04:21 +02:00
project_id: 1
@@ -20,13 +22,15 @@ issues_002:
priority_id: 5
subject: Add ingredients categories
id: 2
- fixed_version_id:
+ fixed_version_id: 2
category_id:
description: Ingredients of the recipe should be classified by categories
tracker_id: 2
assigned_to_id: 3
author_id: 2
status_id: 2
+ start_date: <%= 2.day.ago.to_date.to_s(:db) %>
+ due_date:
issues_003:
created_on: 2006-07-19 21:07:27 +02:00
project_id: 1
diff --git a/test/fixtures/versions.yml b/test/fixtures/versions.yml
index bf08660d5..62c5e6f99 100644
--- a/test/fixtures/versions.yml
+++ b/test/fixtures/versions.yml
@@ -14,7 +14,7 @@ versions_002:
updated_on: 2006-07-19 21:00:33 +02:00
id: 2
description: Stable release
- effective_date: 2006-07-19
+ effective_date: <%= 20.day.from_now.to_date.to_s(:db) %>
versions_003:
created_on: 2006-07-19 21:00:33 +02:00
name: "2.0"
diff --git a/test/functional/projects_controller_test.rb b/test/functional/projects_controller_test.rb
index bebe96f29..82b5bdeb6 100644
--- a/test/functional/projects_controller_test.rb
+++ b/test/functional/projects_controller_test.rb
@@ -259,7 +259,16 @@ class ProjectsControllerTest < Test::Unit::TestCase
get :gantt, :id => 1
assert_response :success
assert_template 'gantt.rhtml'
- assert_not_nil assigns(:events)
+ events = assigns(:events)
+ assert_not_nil events
+ # Issue with start and due dates
+ i = Issue.find(1)
+ assert_not_nil i.due_date
+ assert events.include?(Issue.find(1))
+ # Issue with without due date but targeted to a version with date
+ i = Issue.find(2)
+ assert_nil i.due_date
+ assert events.include?(i)
end
def test_gantt_with_subprojects_should_not_show_private_subprojects
diff --git a/test/functional/versions_controller_test.rb b/test/functional/versions_controller_test.rb
index 3477c5edd..3a118701a 100644
--- a/test/functional/versions_controller_test.rb
+++ b/test/functional/versions_controller_test.rb
@@ -22,7 +22,7 @@ require 'versions_controller'
class VersionsController; def rescue_action(e) raise e end; end
class VersionsControllerTest < Test::Unit::TestCase
- fixtures :projects, :versions, :users, :roles, :members, :enabled_modules
+ fixtures :projects, :versions, :issues, :users, :roles, :members, :enabled_modules
def setup
@controller = VersionsController.new
@@ -60,9 +60,9 @@ class VersionsControllerTest < Test::Unit::TestCase
def test_destroy
@request.session[:user_id] = 2
- post :destroy, :id => 2
+ post :destroy, :id => 3
assert_redirected_to 'projects/settings/ecookbook'
- assert_nil Version.find_by_id(2)
+ assert_nil Version.find_by_id(3)
end
def test_issue_status_by