Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

issue_scopes_test.rb 2.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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 IssueScopesTest < ActiveSupport::TestCase
  19. fixtures :projects, :users, :members, :member_roles, :roles,
  20. :groups_users,
  21. :trackers, :projects_trackers,
  22. :enabled_modules,
  23. :versions, :issue_statuses, :issue_categories, :enumerations,
  24. :issues,
  25. :custom_fields, :custom_fields_projects, :custom_fields_trackers, :custom_values
  26. def setup
  27. User.current = nil
  28. end
  29. def test_cross_project_scope_without_project_should_return_all_issues
  30. ids = Issue.cross_project_scope(nil).pluck(:id).sort
  31. assert_equal Issue.pluck(:id).sort, ids
  32. end
  33. def test_cross_project_scope_with_project_should_return_project_issues
  34. project = Project.find(1)
  35. ids = Issue.cross_project_scope(project).pluck(:id).sort
  36. assert_equal project.issues.pluck(:id).sort, ids
  37. end
  38. def test_cross_project_scope_with_all_scope_should_return_all_issues
  39. project = Project.find(1)
  40. ids = Issue.cross_project_scope(project, 'all').pluck(:id).sort
  41. assert_equal Issue.pluck(:id).sort, ids
  42. end
  43. def test_cross_project_scope_with_system_scope_should_return_all_issues
  44. project = Project.find(1)
  45. ids = Issue.cross_project_scope(project, 'system').pluck(:id).sort
  46. assert_equal Issue.pluck(:id).sort, ids
  47. end
  48. def test_cross_project_scope_with_tree_scope_should_return_tree_issues
  49. project = Project.find(5)
  50. ids = Issue.cross_project_scope(project, 'tree').pluck(:id).sort
  51. assert_equal project.root.self_and_descendants.map{|p| p.issues.pluck(:id)}.flatten.sort, ids
  52. end
  53. def test_cross_project_scope_with_hierarchy_scope_should_return_hierarchy_issues
  54. project = Project.find(5)
  55. ids = Issue.cross_project_scope(project, 'hierarchy').pluck(:id).sort
  56. assert_equal (project.self_and_descendants + project.ancestors).map{|p| p.issues.pluck(:id)}.flatten.sort, ids
  57. end
  58. def test_cross_project_scope_with_descendants_scope_should_return_descendants_issues
  59. project = Project.find(5)
  60. ids = Issue.cross_project_scope(project, 'descendants').pluck(:id).sort
  61. assert_equal project.self_and_descendants.map{|p| p.issues.pluck(:id)}.flatten.sort, ids
  62. end
  63. end