diff options
author | Toshi MARUYAMA <marutosijp2@yahoo.co.jp> | 2013-05-21 13:42:19 +0000 |
---|---|---|
committer | Toshi MARUYAMA <marutosijp2@yahoo.co.jp> | 2013-05-21 13:42:19 +0000 |
commit | 8ea4e79964163187354a48172ee6afd1648396e2 (patch) | |
tree | ad7edd689872f354290798ccbe8f7e99631abad8 /test | |
parent | 596366b062863ea8654536493480437208fcc965 (diff) | |
download | redmine-8ea4e79964163187354a48172ee6afd1648396e2.tar.gz redmine-8ea4e79964163187354a48172ee6afd1648396e2.zip |
gantt: sort issues by start date (#7335)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@11897 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test')
-rw-r--r-- | test/unit/lib/redmine/helpers/gantt_test.rb | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/test/unit/lib/redmine/helpers/gantt_test.rb b/test/unit/lib/redmine/helpers/gantt_test.rb index 6b95b512d..d427ce707 100644 --- a/test/unit/lib/redmine/helpers/gantt_test.rb +++ b/test/unit/lib/redmine/helpers/gantt_test.rb @@ -781,4 +781,51 @@ class Redmine::Helpers::GanttHelperTest < ActionView::TestCase assert_equal [issue1.id, child1.id, child3.id, child2.id, issue2.id], issues.map{|v| v.id} end + + def test_sort_issues_root_only + project = Project.generate! + issue1 = Issue.generate!(:subject => "test", :project => project) + issue2 = Issue.generate!(:subject => "test", :project => project) + issue3 = Issue.generate!(:subject => "test", :project => project, + :start_date => (today - 1)) + issue4 = Issue.generate!(:subject => "test", :project => project, + :start_date => (today - 2)) + issues = [issue4, issue3, issue2, issue1] + Redmine::Helpers::Gantt.sort_issues!(issues) + assert_equal [issue1.id, issue2.id, issue4.id, issue3.id], + issues.map{|v| v.id} + end + + def test_sort_issues_tree + project = Project.generate! + issue1 = Issue.generate!(:subject => "test", :project => project) + issue2 = Issue.generate!(:subject => "test", :project => project, + :start_date => (today - 2)) + issue1_child1 = + Issue.generate!(:parent_issue_id => issue1.id, :subject => 'child', + :project => project) + issue1_child2 = + Issue.generate!(:parent_issue_id => issue1.id, :subject => 'child', + :project => project, :start_date => (today - 10)) + issue1_child1_child1 = + Issue.generate!(:parent_issue_id => issue1_child1.id, :subject => 'child', + :project => project, :start_date => (today - 8)) + issue1_child1_child2 = + Issue.generate!(:parent_issue_id => issue1_child1.id, :subject => 'child', + :project => project, :start_date => (today - 9)) + issue1_child1_child1_logic = Redmine::Helpers::Gantt.sort_issue_logic(issue1_child1_child1) + assert_equal [[today - 10, issue1.id], [today - 9, issue1_child1.id], + [today - 8, issue1_child1_child1.id]], + issue1_child1_child1_logic + issue1_child1_child2_logic = Redmine::Helpers::Gantt.sort_issue_logic(issue1_child1_child2) + assert_equal [[today - 10, issue1.id], [today - 9, issue1_child1.id], + [today - 9, issue1_child1_child2.id]], + issue1_child1_child2_logic + issues = [issue1_child1_child2, issue1_child1_child1, issue1_child2, + issue1_child1, issue2, issue1] + Redmine::Helpers::Gantt.sort_issues!(issues) + assert_equal [issue1.id, issue1_child1.id, issue1_child2.id, + issue1_child1_child2.id, issue1_child1_child1.id, issue2.id], + issues.map{|v| v.id} + end end |