comparison test/functional/gantts_controller_test.rb @ 1295:622f24f53b42 redmine-2.3

Update to Redmine SVN revision 11972 on 2.3-stable branch
author Chris Cannam
date Fri, 14 Jun 2013 09:02:21 +0100
parents 433d4f72a19b
children
comparison
equal deleted inserted replaced
1294:3e4c3460b6ca 1295:622f24f53b42
1 # Redmine - project management software 1 # Redmine - project management software
2 # Copyright (C) 2006-2012 Jean-Philippe Lang 2 # Copyright (C) 2006-2013 Jean-Philippe Lang
3 # 3 #
4 # This program is free software; you can redistribute it and/or 4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License 5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2 6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version. 7 # of the License, or (at your option) any later version.
23 :projects_trackers, 23 :projects_trackers,
24 :roles, 24 :roles,
25 :member_roles, 25 :member_roles,
26 :members, 26 :members,
27 :enabled_modules, 27 :enabled_modules,
28 :workflows,
29 :versions 28 :versions
30 29
31 def test_gantt_should_work 30 def test_gantt_should_work
32 i2 = Issue.find(2) 31 i2 = Issue.find(2)
33 i2.update_attribute(:due_date, 1.month.from_now) 32 i2.update_attribute(:due_date, 1.month.from_now)
34 get :show, :project_id => 1 33 get :show, :project_id => 1
34 assert_response :success
35 assert_template 'gantts/show'
36 assert_not_nil assigns(:gantt)
37 # Issue with start and due dates
38 i = Issue.find(1)
39 assert_not_nil i.due_date
40 assert_select "div a.issue", /##{i.id}/
41 # Issue with on a targeted version should not be in the events but loaded in the html
42 i = Issue.find(2)
43 assert_select "div a.issue", /##{i.id}/
44 end
45
46 def test_gantt_should_work_without_issue_due_dates
47 Issue.update_all("due_date = NULL")
48 get :show, :project_id => 1
49 assert_response :success
50 assert_template 'gantts/show'
51 assert_not_nil assigns(:gantt)
52 end
53
54 def test_gantt_should_work_without_issue_and_version_due_dates
55 Issue.update_all("due_date = NULL")
56 Version.update_all("effective_date = NULL")
57 get :show, :project_id => 1
58 assert_response :success
59 assert_template 'gantts/show'
60 assert_not_nil assigns(:gantt)
61 end
62
63 def test_gantt_should_work_cross_project
64 get :show
65 assert_response :success
66 assert_template 'gantts/show'
67 assert_not_nil assigns(:gantt)
68 assert_not_nil assigns(:gantt).query
69 assert_nil assigns(:gantt).project
70 end
71
72 def test_gantt_should_not_disclose_private_projects
73 get :show
74 assert_response :success
75 assert_template 'gantts/show'
76 assert_tag 'a', :content => /eCookbook/
77 # Root private project
78 assert_no_tag 'a', {:content => /OnlineStore/}
79 # Private children of a public project
80 assert_no_tag 'a', :content => /Private child of eCookbook/
81 end
82
83 def test_gantt_should_display_relations
84 IssueRelation.delete_all
85 issue1 = Issue.generate!(:start_date => 1.day.from_now, :due_date => 3.day.from_now)
86 issue2 = Issue.generate!(:start_date => 1.day.from_now, :due_date => 3.day.from_now)
87 IssueRelation.create!(:issue_from => issue1, :issue_to => issue2, :relation_type => 'precedes')
88
89 get :show
90 assert_response :success
91
92 relations = assigns(:gantt).relations
93 assert_kind_of Hash, relations
94 assert relations.present?
95 assert_select 'div.task_todo[id=?][data-rels*=?]', "task-todo-issue-#{issue1.id}", issue2.id.to_s
96 assert_select 'div.task_todo[id=?]:not([data-rels])', "task-todo-issue-#{issue2.id}"
97 end
98
99 def test_gantt_should_export_to_pdf
100 get :show, :project_id => 1, :format => 'pdf'
101 assert_response :success
102 assert_equal 'application/pdf', @response.content_type
103 assert @response.body.starts_with?('%PDF')
104 assert_not_nil assigns(:gantt)
105 end
106
107 def test_gantt_should_export_to_pdf_cross_project
108 get :show, :format => 'pdf'
109 assert_response :success
110 assert_equal 'application/pdf', @response.content_type
111 assert @response.body.starts_with?('%PDF')
112 assert_not_nil assigns(:gantt)
113 end
114
115 if Object.const_defined?(:Magick)
116 def test_gantt_should_export_to_png
117 get :show, :project_id => 1, :format => 'png'
35 assert_response :success 118 assert_response :success
36 assert_template 'gantts/show' 119 assert_equal 'image/png', @response.content_type
37 assert_not_nil assigns(:gantt)
38 # Issue with start and due dates
39 i = Issue.find(1)
40 assert_not_nil i.due_date
41 assert_select "div a.issue", /##{i.id}/
42 # Issue with on a targeted version should not be in the events but loaded in the html
43 i = Issue.find(2)
44 assert_select "div a.issue", /##{i.id}/
45 end 120 end
46 121 end
47 def test_gantt_should_work_without_issue_due_dates
48 Issue.update_all("due_date = NULL")
49 get :show, :project_id => 1
50 assert_response :success
51 assert_template 'gantts/show'
52 assert_not_nil assigns(:gantt)
53 end
54
55 def test_gantt_should_work_without_issue_and_version_due_dates
56 Issue.update_all("due_date = NULL")
57 Version.update_all("effective_date = NULL")
58 get :show, :project_id => 1
59 assert_response :success
60 assert_template 'gantts/show'
61 assert_not_nil assigns(:gantt)
62 end
63
64 def test_gantt_should_work_cross_project
65 get :show
66 assert_response :success
67 assert_template 'gantts/show'
68 assert_not_nil assigns(:gantt)
69 assert_not_nil assigns(:gantt).query
70 assert_nil assigns(:gantt).project
71 end
72
73 def test_gantt_should_not_disclose_private_projects
74 get :show
75 assert_response :success
76 assert_template 'gantts/show'
77 assert_tag 'a', :content => /eCookbook/
78 # Root private project
79 assert_no_tag 'a', {:content => /OnlineStore/}
80 # Private children of a public project
81 assert_no_tag 'a', :content => /Private child of eCookbook/
82 end
83
84 def test_gantt_should_export_to_pdf
85 get :show, :project_id => 1, :format => 'pdf'
86 assert_response :success
87 assert_equal 'application/pdf', @response.content_type
88 assert @response.body.starts_with?('%PDF')
89 assert_not_nil assigns(:gantt)
90 end
91
92 def test_gantt_should_export_to_pdf_cross_project
93 get :show, :format => 'pdf'
94 assert_response :success
95 assert_equal 'application/pdf', @response.content_type
96 assert @response.body.starts_with?('%PDF')
97 assert_not_nil assigns(:gantt)
98 end
99
100 if Object.const_defined?(:Magick)
101 def test_gantt_should_export_to_png
102 get :show, :project_id => 1, :format => 'png'
103 assert_response :success
104 assert_equal 'image/png', @response.content_type
105 end
106 end
107 end 122 end