Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

gantts_controller_test.rb 5.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. # frozen_string_literal: true
  2. # Redmine - project management software
  3. # Copyright (C) 2006-2019 Jean-Philippe Lang
  4. #
  5. # This program is free software; you can redistribute it and/or
  6. # modify it under the terms of the GNU General Public License
  7. # as published by the Free Software Foundation; either version 2
  8. # of the License, or (at your option) any later version.
  9. #
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # GNU General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License
  16. # along with this program; if not, write to the Free Software
  17. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  18. require File.expand_path('../../test_helper', __FILE__)
  19. class GanttsControllerTest < Redmine::ControllerTest
  20. fixtures :projects, :trackers, :issue_statuses, :issues,
  21. :enumerations, :users, :issue_categories,
  22. :projects_trackers,
  23. :roles,
  24. :member_roles,
  25. :members,
  26. :enabled_modules,
  27. :versions,
  28. :email_addresses
  29. def test_gantt_should_work
  30. i2 = Issue.find(2)
  31. i2.update_attribute(:due_date, 1.month.from_now)
  32. with_settings :gravatar_enabled => '1' do
  33. get :show, :params => {
  34. :project_id => 1
  35. }
  36. end
  37. assert_response :success
  38. # query form
  39. assert_select 'form#query_form' do
  40. assert_select 'div#query_form_with_buttons.hide-when-print' do
  41. assert_select 'div#query_form_content' do
  42. assert_select 'fieldset#filters.collapsible'
  43. assert_select 'fieldset#options'
  44. end
  45. assert_select 'p.contextual'
  46. assert_select 'p.buttons'
  47. end
  48. end
  49. # Assert context menu on issues subject and gantt bar
  50. assert_select 'div[class=?]', 'issue-subject hascontextmenu'
  51. assert_select 'div.tooltip.hascontextmenu' do
  52. assert_select 'img[class="gravatar"]'
  53. end
  54. assert_select "form[data-cm-url=?]", '/issues/context_menu'
  55. # Issue with start and due dates
  56. i = Issue.find(1)
  57. assert_not_nil i.due_date
  58. assert_select "div a.issue", /##{i.id}/
  59. # Issue with on a targeted version should not be in the events but loaded in the html
  60. i = Issue.find(2)
  61. assert_select "div a.issue", /##{i.id}/
  62. end
  63. def test_gantt_at_minimal_zoom
  64. get :show, :params => {
  65. :project_id => 1,
  66. :zoom => 1
  67. }
  68. assert_response :success
  69. assert_select 'input[type=hidden][name=zoom][value=?]', '1'
  70. end
  71. def test_gantt_at_maximal_zoom
  72. get :show, :params => {
  73. :project_id => 1,
  74. :zoom => 4
  75. }
  76. assert_response :success
  77. assert_select 'input[type=hidden][name=zoom][value=?]', '4'
  78. end
  79. def test_gantt_should_work_without_issue_due_dates
  80. Issue.update_all("due_date = NULL")
  81. get :show, :params => {
  82. :project_id => 1
  83. }
  84. assert_response :success
  85. end
  86. def test_gantt_should_work_without_issue_and_version_due_dates
  87. Issue.update_all("due_date = NULL")
  88. Version.update_all("effective_date = NULL")
  89. get :show, :params => {
  90. :project_id => 1
  91. }
  92. assert_response :success
  93. end
  94. def test_gantt_should_work_cross_project
  95. get :show
  96. assert_response :success
  97. end
  98. def test_gantt_should_not_disclose_private_projects
  99. get :show
  100. assert_response :success
  101. assert_select 'a', :text => /eCookbook/
  102. # Root private project
  103. assert_select 'a', :text => /OnlineStore/, :count => 0
  104. # Private children of a public project
  105. assert_select 'a', :text => /Private child of eCookbook/, :count => 0
  106. end
  107. def test_gantt_should_display_relations
  108. IssueRelation.delete_all
  109. issue1 = Issue.generate!(:start_date => 1.day.from_now.to_date, :due_date => 3.day.from_now.to_date)
  110. issue2 = Issue.generate!(:start_date => 1.day.from_now.to_date, :due_date => 3.day.from_now.to_date)
  111. IssueRelation.create!(:issue_from => issue1, :issue_to => issue2, :relation_type => 'precedes')
  112. get :show
  113. assert_response :success
  114. assert_select 'div.task_todo[id=?][data-rels*=?]', "task-todo-issue-#{issue1.id}", issue2.id.to_s
  115. assert_select 'div.task_todo[id=?]:not([data-rels])', "task-todo-issue-#{issue2.id}"
  116. end
  117. def test_gantt_should_export_to_pdf
  118. get :show, :params => {
  119. :project_id => 1,
  120. :format => 'pdf'
  121. }
  122. assert_response :success
  123. assert_equal 'application/pdf', @response.content_type
  124. assert @response.body.starts_with?('%PDF')
  125. end
  126. def test_gantt_should_export_to_pdf_cross_project
  127. get :show, :params => {
  128. :format => 'pdf'
  129. }
  130. assert_response :success
  131. assert_equal 'application/pdf', @response.content_type
  132. assert @response.body.starts_with?('%PDF')
  133. end
  134. if Object.const_defined?(:Magick)
  135. def test_gantt_should_export_to_png
  136. get :show, :params => {
  137. :project_id => 1,
  138. :format => 'png'
  139. }
  140. assert_response :success
  141. assert_equal 'image/png', @response.content_type
  142. end
  143. end
  144. def test_gantt_should_respect_gantt_months_limit_setting
  145. with_settings :gantt_months_limit => '40' do
  146. # `months` parameter can be less than or equal to
  147. # `Setting.gantt_months_limit`
  148. get :show, :params => {
  149. :project_id => 1,
  150. :zoom => 4,
  151. :months => 40
  152. }
  153. assert_response :success
  154. assert_select 'div.gantt_hdr>a', :text => /^[\d-]+$/, :count => 40
  155. # Displays 6 months (the default value for `months`) if `months` exceeds
  156. # gant_months_limit
  157. get :show, :params => {
  158. :project_id => 1,
  159. :zoom => 4,
  160. :months => 41
  161. }
  162. assert_response :success
  163. assert_select 'div.gantt_hdr>a', :text => /^[\d-]+$/, :count => 6
  164. end
  165. end
  166. end