You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

gantts_controller_test.rb 5.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. # Redmine - project management software
  2. # Copyright (C) 2006-2017 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. require File.expand_path('../../test_helper', __FILE__)
  18. class GanttsControllerTest < Redmine::ControllerTest
  19. fixtures :projects, :trackers, :issue_statuses, :issues,
  20. :enumerations, :users, :issue_categories,
  21. :projects_trackers,
  22. :roles,
  23. :member_roles,
  24. :members,
  25. :enabled_modules,
  26. :versions
  27. def test_gantt_should_work
  28. i2 = Issue.find(2)
  29. i2.update_attribute(:due_date, 1.month.from_now)
  30. with_settings :gravatar_enabled => '1' do
  31. get :show, :params => {
  32. :project_id => 1
  33. }
  34. end
  35. assert_response :success
  36. # query form
  37. assert_select 'form#query_form' do
  38. assert_select 'div#query_form_with_buttons.hide-when-print' do
  39. assert_select 'div#query_form_content' do
  40. assert_select 'fieldset#filters.collapsible'
  41. assert_select 'fieldset#options'
  42. end
  43. assert_select 'p.contextual'
  44. assert_select 'p.buttons'
  45. end
  46. end
  47. # Assert context menu on issues subject and gantt bar
  48. assert_select 'div[class=?]', 'issue-subject hascontextmenu'
  49. assert_select 'div.tooltip.hascontextmenu' do
  50. assert_select 'img[class="gravatar"]'
  51. end
  52. assert_select "form[data-cm-url=?]", '/issues/context_menu'
  53. # Issue with start and due dates
  54. i = Issue.find(1)
  55. assert_not_nil i.due_date
  56. assert_select "div a.issue", /##{i.id}/
  57. # Issue with on a targeted version should not be in the events but loaded in the html
  58. i = Issue.find(2)
  59. assert_select "div a.issue", /##{i.id}/
  60. end
  61. def test_gantt_at_minimal_zoom
  62. get :show, :params => {
  63. :project_id => 1,
  64. :zoom => 1
  65. }
  66. assert_response :success
  67. assert_select 'input[type=hidden][name=zoom][value=?]', '1'
  68. end
  69. def test_gantt_at_maximal_zoom
  70. get :show, :params => {
  71. :project_id => 1,
  72. :zoom => 4
  73. }
  74. assert_response :success
  75. assert_select 'input[type=hidden][name=zoom][value=?]', '4'
  76. end
  77. def test_gantt_should_work_without_issue_due_dates
  78. Issue.update_all("due_date = NULL")
  79. get :show, :params => {
  80. :project_id => 1
  81. }
  82. assert_response :success
  83. end
  84. def test_gantt_should_work_without_issue_and_version_due_dates
  85. Issue.update_all("due_date = NULL")
  86. Version.update_all("effective_date = NULL")
  87. get :show, :params => {
  88. :project_id => 1
  89. }
  90. assert_response :success
  91. end
  92. def test_gantt_should_work_cross_project
  93. get :show
  94. assert_response :success
  95. end
  96. def test_gantt_should_not_disclose_private_projects
  97. get :show
  98. assert_response :success
  99. assert_select 'a', :text => /eCookbook/
  100. # Root private project
  101. assert_select 'a', :text => /OnlineStore/, :count => 0
  102. # Private children of a public project
  103. assert_select 'a', :text => /Private child of eCookbook/, :count => 0
  104. end
  105. def test_gantt_should_display_relations
  106. IssueRelation.delete_all
  107. issue1 = Issue.generate!(:start_date => 1.day.from_now.to_date, :due_date => 3.day.from_now.to_date)
  108. issue2 = Issue.generate!(:start_date => 1.day.from_now.to_date, :due_date => 3.day.from_now.to_date)
  109. IssueRelation.create!(:issue_from => issue1, :issue_to => issue2, :relation_type => 'precedes')
  110. get :show
  111. assert_response :success
  112. assert_select 'div.task_todo[id=?][data-rels*=?]', "task-todo-issue-#{issue1.id}", issue2.id.to_s
  113. assert_select 'div.task_todo[id=?]:not([data-rels])', "task-todo-issue-#{issue2.id}"
  114. end
  115. def test_gantt_should_export_to_pdf
  116. get :show, :params => {
  117. :project_id => 1,
  118. :format => 'pdf'
  119. }
  120. assert_response :success
  121. assert_equal 'application/pdf', @response.content_type
  122. assert @response.body.starts_with?('%PDF')
  123. end
  124. def test_gantt_should_export_to_pdf_cross_project
  125. get :show, :params => {
  126. :format => 'pdf'
  127. }
  128. assert_response :success
  129. assert_equal 'application/pdf', @response.content_type
  130. assert @response.body.starts_with?('%PDF')
  131. end
  132. if Object.const_defined?(:Magick)
  133. def test_gantt_should_export_to_png
  134. get :show, :params => {
  135. :project_id => 1,
  136. :format => 'png'
  137. }
  138. assert_response :success
  139. assert_equal 'image/png', @response.content_type
  140. end
  141. end
  142. end