@@ -1,123 +1,123 | |||
|
1 | 1 | # Redmine - project management software |
|
2 | 2 | # Copyright (C) 2006-2012 Jean-Philippe Lang |
|
3 | 3 | # |
|
4 | 4 | # This program is free software; you can redistribute it and/or |
|
5 | 5 | # modify it under the terms of the GNU General Public License |
|
6 | 6 | # as published by the Free Software Foundation; either version 2 |
|
7 | 7 | # of the License, or (at your option) any later version. |
|
8 | 8 | # |
|
9 | 9 | # This program is distributed in the hope that it will be useful, |
|
10 | 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | 12 | # GNU General Public License for more details. |
|
13 | 13 | # |
|
14 | 14 | # You should have received a copy of the GNU General Public License |
|
15 | 15 | # along with this program; if not, write to the Free Software |
|
16 | 16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
17 | 17 | |
|
18 | 18 | require File.expand_path('../../test_helper', __FILE__) |
|
19 | 19 | |
|
20 | 20 | class GanttsControllerTest < ActionController::TestCase |
|
21 | 21 | fixtures :projects, :trackers, :issue_statuses, :issues, |
|
22 | 22 | :enumerations, :users, :issue_categories, |
|
23 | 23 | :projects_trackers, |
|
24 | 24 | :roles, |
|
25 | 25 | :member_roles, |
|
26 | 26 | :members, |
|
27 | 27 | :enabled_modules, |
|
28 | 28 | :workflows, |
|
29 | 29 | :versions |
|
30 | 30 | |
|
31 | 31 | def test_gantt_should_work |
|
32 | 32 | i2 = Issue.find(2) |
|
33 | 33 | i2.update_attribute(:due_date, 1.month.from_now) |
|
34 | 34 | get :show, :project_id => 1 |
|
35 | 35 | assert_response :success |
|
36 | 36 | assert_template 'gantts/show' |
|
37 | 37 | assert_not_nil assigns(:gantt) |
|
38 | 38 | # Issue with start and due dates |
|
39 | 39 | i = Issue.find(1) |
|
40 | 40 | assert_not_nil i.due_date |
|
41 | 41 | assert_select "div a.issue", /##{i.id}/ |
|
42 | 42 | # Issue with on a targeted version should not be in the events but loaded in the html |
|
43 | 43 | i = Issue.find(2) |
|
44 | 44 | assert_select "div a.issue", /##{i.id}/ |
|
45 | 45 | end |
|
46 | 46 | |
|
47 | 47 | def test_gantt_should_work_without_issue_due_dates |
|
48 | 48 | Issue.update_all("due_date = NULL") |
|
49 | 49 | get :show, :project_id => 1 |
|
50 | 50 | assert_response :success |
|
51 | 51 | assert_template 'gantts/show' |
|
52 | 52 | assert_not_nil assigns(:gantt) |
|
53 | 53 | end |
|
54 | 54 | |
|
55 | 55 | def test_gantt_should_work_without_issue_and_version_due_dates |
|
56 | 56 | Issue.update_all("due_date = NULL") |
|
57 | 57 | Version.update_all("effective_date = NULL") |
|
58 | 58 | get :show, :project_id => 1 |
|
59 | 59 | assert_response :success |
|
60 | 60 | assert_template 'gantts/show' |
|
61 | 61 | assert_not_nil assigns(:gantt) |
|
62 | 62 | end |
|
63 | 63 | |
|
64 | 64 | def test_gantt_should_work_cross_project |
|
65 | 65 | get :show |
|
66 | 66 | assert_response :success |
|
67 | 67 | assert_template 'gantts/show' |
|
68 | 68 | assert_not_nil assigns(:gantt) |
|
69 | 69 | assert_not_nil assigns(:gantt).query |
|
70 | 70 | assert_nil assigns(:gantt).project |
|
71 | 71 | end |
|
72 | 72 | |
|
73 | 73 | def test_gantt_should_not_disclose_private_projects |
|
74 | 74 | get :show |
|
75 | 75 | assert_response :success |
|
76 | 76 | assert_template 'gantts/show' |
|
77 | 77 | assert_tag 'a', :content => /eCookbook/ |
|
78 | 78 | # Root private project |
|
79 | 79 | assert_no_tag 'a', {:content => /OnlineStore/} |
|
80 | 80 | # Private children of a public project |
|
81 | 81 | assert_no_tag 'a', :content => /Private child of eCookbook/ |
|
82 | 82 | end |
|
83 | 83 | |
|
84 | 84 | def test_gantt_should_display_relations |
|
85 | 85 | IssueRelation.delete_all |
|
86 | 86 | issue1 = Issue.generate!(:start_date => 1.day.from_now, :due_date => 3.day.from_now) |
|
87 | 87 | issue2 = Issue.generate!(:start_date => 1.day.from_now, :due_date => 3.day.from_now) |
|
88 | 88 | IssueRelation.create!(:issue_from => issue1, :issue_to => issue2, :relation_type => 'precedes') |
|
89 | 89 | |
|
90 | 90 | get :show |
|
91 | 91 | assert_response :success |
|
92 | 92 | |
|
93 | 93 | relations = assigns(:gantt).relations |
|
94 | 94 | assert_kind_of Hash, relations |
|
95 | 95 | assert relations.present? |
|
96 | 96 | assert_select 'div.task_todo[id=?][data-rels*=?]', "task-todo-issue-#{issue1.id}", issue2.id.to_s |
|
97 |
assert_select 'div.task_todo[id=?][data-rels |
|
|
97 | assert_select 'div.task_todo[id=?]:not([data-rels])', "task-todo-issue-#{issue2.id}" | |
|
98 | 98 | end |
|
99 | 99 | |
|
100 | 100 | def test_gantt_should_export_to_pdf |
|
101 | 101 | get :show, :project_id => 1, :format => 'pdf' |
|
102 | 102 | assert_response :success |
|
103 | 103 | assert_equal 'application/pdf', @response.content_type |
|
104 | 104 | assert @response.body.starts_with?('%PDF') |
|
105 | 105 | assert_not_nil assigns(:gantt) |
|
106 | 106 | end |
|
107 | 107 | |
|
108 | 108 | def test_gantt_should_export_to_pdf_cross_project |
|
109 | 109 | get :show, :format => 'pdf' |
|
110 | 110 | assert_response :success |
|
111 | 111 | assert_equal 'application/pdf', @response.content_type |
|
112 | 112 | assert @response.body.starts_with?('%PDF') |
|
113 | 113 | assert_not_nil assigns(:gantt) |
|
114 | 114 | end |
|
115 | 115 | |
|
116 | 116 | if Object.const_defined?(:Magick) |
|
117 | 117 | def test_gantt_should_export_to_png |
|
118 | 118 | get :show, :project_id => 1, :format => 'png' |
|
119 | 119 | assert_response :success |
|
120 | 120 | assert_equal 'image/png', @response.content_type |
|
121 | 121 | end |
|
122 | 122 | end |
|
123 | 123 | end |
General Comments 0
You need to be logged in to leave comments.
Login now