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.

auto_completes_controller_test.rb 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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 AutoCompletesControllerTest < Redmine::ControllerTest
  19. fixtures :projects, :issues, :issue_statuses,
  20. :enumerations, :users, :issue_categories,
  21. :trackers,
  22. :projects_trackers,
  23. :roles,
  24. :member_roles,
  25. :members,
  26. :enabled_modules,
  27. :journals, :journal_details
  28. def test_issues_should_not_be_case_sensitive
  29. get :issues, :params => {
  30. :project_id => 'ecookbook',
  31. :q => 'ReCiPe'
  32. }
  33. assert_response :success
  34. assert_include "recipe", response.body
  35. end
  36. def test_issues_should_accept_term_param
  37. get :issues, :params => {
  38. :project_id => 'ecookbook',
  39. :term => 'ReCiPe'
  40. }
  41. assert_response :success
  42. assert_include "recipe", response.body
  43. end
  44. def test_issues_should_return_issue_with_given_id
  45. get :issues, :params => {
  46. :project_id => 'subproject1',
  47. :q => '13'
  48. }
  49. assert_response :success
  50. assert_include "Bug #13", response.body
  51. end
  52. def test_issues_should_return_issue_with_given_id_preceded_with_hash
  53. get :issues, :params => {
  54. :project_id => 'subproject1',
  55. :q => '#13'
  56. }
  57. assert_response :success
  58. assert_include "Bug #13", response.body
  59. end
  60. def test_auto_complete_with_scope_all_should_search_other_projects
  61. get :issues, :params => {
  62. :project_id => 'ecookbook',
  63. :q => '13',
  64. :scope => 'all'
  65. }
  66. assert_response :success
  67. assert_include "Bug #13", response.body
  68. end
  69. def test_auto_complete_without_project_should_search_all_projects
  70. get :issues, :params => {
  71. :q => '13'
  72. }
  73. assert_response :success
  74. assert_include "Bug #13", response.body
  75. end
  76. def test_auto_complete_without_scope_all_should_not_search_other_projects
  77. get :issues, :params => {
  78. :project_id => 'ecookbook',
  79. :q => '13'
  80. }
  81. assert_response :success
  82. assert_not_include "Bug #13", response.body
  83. end
  84. def test_issues_should_return_json
  85. get :issues, :params => {
  86. :project_id => 'subproject1',
  87. :q => '13'
  88. }
  89. assert_response :success
  90. json = ActiveSupport::JSON.decode(response.body)
  91. assert_kind_of Array, json
  92. issue = json.first
  93. assert_kind_of Hash, issue
  94. assert_equal 13, issue['id']
  95. assert_equal 13, issue['value']
  96. assert_equal 'Bug #13: Subproject issue two', issue['label']
  97. end
  98. def test_auto_complete_with_status_o_should_return_open_issues_only
  99. get :issues, :params => {
  100. :project_id => 'ecookbook',
  101. :q => 'issue',
  102. :status => 'o'
  103. }
  104. assert_response :success
  105. assert_include "Issue due today", response.body
  106. assert_not_include "closed", response.body
  107. end
  108. def test_auto_complete_with_status_c_should_return_closed_issues_only
  109. get :issues, :params => {
  110. :project_id => 'ecookbook',
  111. :q => 'issue',
  112. :status => 'c'
  113. }
  114. assert_response :success
  115. assert_include "closed", response.body
  116. assert_not_include "Issue due today", response.body
  117. end
  118. def test_auto_complete_with_issue_id_should_not_return_that_issue
  119. get :issues, :params => {
  120. :project_id => 'ecookbook',
  121. :q => 'issue',
  122. :issue_id => '12'
  123. }
  124. assert_response :success
  125. assert_include "issue", response.body
  126. assert_not_include "Bug #12: Closed issue on a locked version", response.body
  127. end
  128. end