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