@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
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
\r
if i.is_a? Issue\r
i_start_date = (i.start_date >= @date_from ? i.start_date : @date_from )\r
- i_end_date = (i.due_date <= @date_to ? i.due_date : @date_to )\r
+ i_end_date = (i.due_before <= @date_to ? i.due_before : @date_to )\r
\r
- i_done_date = i.start_date + ((i.due_date - i.start_date+1)*i.done_ratio/100).floor\r
+ i_done_date = i.start_date + ((i.due_before - i.start_date+1)*i.done_ratio/100).floor\r
i_done_date = (i_done_date <= @date_from ? @date_from : i_done_date )\r
i_done_date = (i_done_date >= @date_to ? @date_to : i_done_date )\r
\r
@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 )
assigned_to_id: \r
author_id: 2\r
status_id: 1\r
+ start_date: <%= 1.day.ago.to_date.to_s(:db) %>\r
+ due_date: <%= 10.day.from_now.to_date.to_s(:db) %>\r
issues_002: \r
created_on: 2006-07-19 21:04:21 +02:00\r
project_id: 1\r
priority_id: 5\r
subject: Add ingredients categories\r
id: 2\r
- fixed_version_id: \r
+ fixed_version_id: 2\r
category_id: \r
description: Ingredients of the recipe should be classified by categories\r
tracker_id: 2\r
assigned_to_id: 3\r
author_id: 2\r
status_id: 2\r
+ start_date: <%= 2.day.ago.to_date.to_s(:db) %>\r
+ due_date: \r
issues_003: \r
created_on: 2006-07-19 21:07:27 +02:00\r
project_id: 1\r
updated_on: 2006-07-19 21:00:33 +02:00\r
id: 2\r
description: Stable release\r
- effective_date: 2006-07-19\r
+ effective_date: <%= 20.day.from_now.to_date.to_s(:db) %>\r
versions_003: \r
created_on: 2006-07-19 21:00:33 +02:00\r
name: "2.0"\r
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
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
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