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.

reports_controller_test.rb 6.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  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 ReportsControllerTest < 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. :workflows
  28. def test_get_issue_report
  29. get :issue_report, :params => {
  30. :id => 1
  31. }
  32. assert_response :success
  33. end
  34. def test_issue_report_with_subprojects_issues
  35. Setting.stubs(:display_subprojects_issues?).returns(true)
  36. get :issue_report, :params => {
  37. :id => 1
  38. }
  39. assert_response :success
  40. # Count subprojects issues
  41. assert_select 'table.list tbody :nth-child(1):first' do
  42. assert_select 'td', :text => 'Bug'
  43. assert_select ':nth-child(2)', :text => '5' # open
  44. assert_select ':nth-child(3)', :text => '3' # closed
  45. assert_select ':nth-child(4)', :text => '8' # total
  46. end
  47. end
  48. def test_issue_report_without_subprojects_issues
  49. Setting.stubs(:display_subprojects_issues?).returns(false)
  50. get :issue_report, :params => {
  51. :id => 1
  52. }
  53. assert_response :success
  54. # Do not count subprojects issues
  55. assert_select 'table.list tbody :nth-child(1):first' do
  56. assert_select 'td', :text => 'Bug'
  57. assert_select ':nth-child(2)', :text => '3' # open
  58. assert_select ':nth-child(3)', :text => '3' # closed
  59. assert_select ':nth-child(4)', :text => '6' # total
  60. end
  61. end
  62. def test_get_issue_report_details
  63. %w(tracker version priority category assigned_to author subproject).each do |detail|
  64. get :issue_report_details, :params => {
  65. :id => 1,
  66. :detail => detail
  67. }
  68. assert_response :success
  69. end
  70. end
  71. def test_get_issue_report_details_by_tracker_should_show_only_statuses_used_by_the_project
  72. Setting.stubs(:display_subprojects_issues?).returns(false)
  73. WorkflowTransition.delete_all
  74. WorkflowTransition.create(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 5)
  75. WorkflowTransition.create(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 4)
  76. WorkflowTransition.create(:role_id => 1, :tracker_id => 1, :old_status_id => 2, :new_status_id => 5)
  77. WorkflowTransition.create(:role_id => 1, :tracker_id => 2, :old_status_id => 1, :new_status_id => 6)
  78. get :issue_report_details, :params => {
  79. :id => 1,
  80. :detail => 'tracker'
  81. }
  82. assert_response :success
  83. assert_select 'table.list tbody :nth-child(1)' do
  84. assert_select 'td', :text => 'Bug'
  85. assert_select ':nth-child(2)', :text => '3' # status:1
  86. assert_select ':nth-child(3)', :text => '-' # status:2
  87. assert_select ':nth-child(4)', :text => '-' # status:4
  88. assert_select ':nth-child(5)', :text => '3' # status:5
  89. assert_select ':nth-child(6)', :text => '-' # status:6
  90. assert_select ':nth-child(7)', :text => '3' # open
  91. assert_select ':nth-child(8)', :text => '3' # closed
  92. assert_select ':nth-child(9)', :text => '6' # total
  93. end
  94. end
  95. def test_get_issue_report_details_by_tracker_with_subprojects_issues
  96. Setting.stubs(:display_subprojects_issues?).returns(true)
  97. get :issue_report_details, :params => {
  98. :id => 1,
  99. :detail => 'tracker'
  100. }
  101. assert_response :success
  102. # Count subprojects issues
  103. assert_select 'table.list tbody :nth-child(1)' do
  104. assert_select 'td', :text => 'Bug'
  105. assert_select ':nth-child(2)', :text => '5' # status:1
  106. assert_select ':nth-child(3)', :text => '-' # status:2
  107. assert_select ':nth-child(4)', :text => '-' # status:3
  108. assert_select ':nth-child(5)', :text => '-' # status:4
  109. assert_select ':nth-child(6)', :text => '3' # status:5
  110. assert_select ':nth-child(7)', :text => '-' # status:6
  111. assert_select ':nth-child(8)', :text => '5' # open
  112. assert_select ':nth-child(9)', :text => '3' # closed
  113. assert_select ':nth-child(10)', :text => '8' # total
  114. end
  115. end
  116. def test_get_issue_report_details_by_tracker_without_subprojects_issues
  117. Setting.stubs(:display_subprojects_issues?).returns(false)
  118. get :issue_report_details, :params => {
  119. :id => 1,
  120. :detail => 'tracker'
  121. }
  122. assert_response :success
  123. # Do not count subprojects issues
  124. assert_select 'table.list tbody :nth-child(1)' do
  125. assert_select 'td', :text => 'Bug'
  126. assert_select ':nth-child(2)', :text => '3' # status:1
  127. assert_select ':nth-child(3)', :text => '-' # status:2
  128. assert_select ':nth-child(4)', :text => '-' # status:3
  129. assert_select ':nth-child(5)', :text => '-' # status:4
  130. assert_select ':nth-child(6)', :text => '3' # status:5
  131. assert_select ':nth-child(7)', :text => '-' # status:6
  132. assert_select ':nth-child(8)', :text => '3' # open
  133. assert_select ':nth-child(9)', :text => '3' # closed
  134. assert_select ':nth-child(10)', :text => '6' # total
  135. end
  136. end
  137. def test_get_issue_report_details_by_tracker_should_show_issue_count
  138. Issue.delete_all
  139. Issue.generate!(:tracker_id => 1)
  140. Issue.generate!(:tracker_id => 1)
  141. Issue.generate!(:tracker_id => 1, :status_id => 5)
  142. Issue.generate!(:tracker_id => 2)
  143. get :issue_report_details, :params => {
  144. :id => 1,
  145. :detail => 'tracker'
  146. }
  147. assert_select 'table.list tbody :nth-child(1)' do
  148. assert_select 'td', :text => 'Bug'
  149. assert_select ':nth-child(2)', :text => '2' # status:1
  150. assert_select ':nth-child(3)', :text => '-' # status:2
  151. assert_select ':nth-child(8)', :text => '2' # open
  152. assert_select ':nth-child(9)', :text => '1' # closed
  153. assert_select ':nth-child(10)', :text => '3' # total
  154. end
  155. end
  156. def test_get_issue_report_details_with_an_invalid_detail
  157. get :issue_report_details, :params => {
  158. :id => 1,
  159. :detail => 'invalid'
  160. }
  161. assert_response 404
  162. end
  163. end