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

Converted routing and urls to follow the Rails REST convention. Patch supplied by commits from Gerrit Kaiser on Github. Existing routes will still work (backwards compatible) but any new urls will be generated using the new routing rules. Changes listed below: * made the URLs for some project tabs and project settings follow the new rails RESTful conventions of /collection/:id/subcollection/:sub_id * prettier URL for project roadmap * more nice project URLs * use GET for filtering form * prettified URLs used on issues tab * custom route for activity atom feeds * prettier repository urls * fixed broken route definition * fixed failing tests for issuecontroller that were hardcoding the url string * more RESTful routes for boards and messages * RESTful routes for wiki pages * RESTful routes for documents * moved old routes that are retained for compatibility to the bottom and grouped them together * added RESTful URIs for issues * RESTfulness for the news section * fixed route order * changed hardcoded URLs in tests * fixed badly written tests * fixed forgotten parameter in routes * changed hardcoded URLS to new scheme * changed project add url to the standard POST to collection * create new issue by POSTing to collection * changed hardcoded URLs in integrations tests * made project add form work again * restful routes for project deletion * prettier routes for project (un)archival * made routes table more readable * fixed note quoting * user routing * fixed bug * always sort by GET * Fixed: cross-project issue list should not show issues of projects for which the issue tracking module was disabled. * prettified URLs used on issues tab * urls for time log * fixed reply routing * eliminate revision query paremeter for diff and entry actions * fixed test failures with hard-coded urls * ensure ajax links always use get * refactored ajax link generation into separate method #1901 git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2317 e93f8b46-1217-0410-a6f0-8f06a7374b81
15 years ago
Converted routing and urls to follow the Rails REST convention. Patch supplied by commits from Gerrit Kaiser on Github. Existing routes will still work (backwards compatible) but any new urls will be generated using the new routing rules. Changes listed below: * made the URLs for some project tabs and project settings follow the new rails RESTful conventions of /collection/:id/subcollection/:sub_id * prettier URL for project roadmap * more nice project URLs * use GET for filtering form * prettified URLs used on issues tab * custom route for activity atom feeds * prettier repository urls * fixed broken route definition * fixed failing tests for issuecontroller that were hardcoding the url string * more RESTful routes for boards and messages * RESTful routes for wiki pages * RESTful routes for documents * moved old routes that are retained for compatibility to the bottom and grouped them together * added RESTful URIs for issues * RESTfulness for the news section * fixed route order * changed hardcoded URLs in tests * fixed badly written tests * fixed forgotten parameter in routes * changed hardcoded URLS to new scheme * changed project add url to the standard POST to collection * create new issue by POSTing to collection * changed hardcoded URLs in integrations tests * made project add form work again * restful routes for project deletion * prettier routes for project (un)archival * made routes table more readable * fixed note quoting * user routing * fixed bug * always sort by GET * Fixed: cross-project issue list should not show issues of projects for which the issue tracking module was disabled. * prettified URLs used on issues tab * urls for time log * fixed reply routing * eliminate revision query paremeter for diff and entry actions * fixed test failures with hard-coded urls * ensure ajax links always use get * refactored ajax link generation into separate method #1901 git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2317 e93f8b46-1217-0410-a6f0-8f06a7374b81
15 years ago
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