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.

issue_scopes_test.rb 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. # Redmine - project management software
  2. # Copyright (C) 2006-2015 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 test_cross_project_scope_without_project_should_return_all_issues
  27. ids = Issue.cross_project_scope(nil).pluck(:id).sort
  28. assert_equal Issue.pluck(:id).sort, ids
  29. end
  30. def test_cross_project_scope_with_project_should_return_project_issues
  31. project = Project.find(1)
  32. ids = Issue.cross_project_scope(project).pluck(:id).sort
  33. assert_equal project.issues.pluck(:id).sort, ids
  34. end
  35. def test_cross_project_scope_with_all_scope_should_return_all_issues
  36. project = Project.find(1)
  37. ids = Issue.cross_project_scope(project, 'all').pluck(:id).sort
  38. assert_equal Issue.pluck(:id).sort, ids
  39. end
  40. def test_cross_project_scope_with_system_scope_should_return_all_issues
  41. project = Project.find(1)
  42. ids = Issue.cross_project_scope(project, 'system').pluck(:id).sort
  43. assert_equal Issue.pluck(:id).sort, ids
  44. end
  45. def test_cross_project_scope_with_tree_scope_should_return_tree_issues
  46. project = Project.find(5)
  47. ids = Issue.cross_project_scope(project, 'tree').pluck(:id).sort
  48. assert_equal project.root.self_and_descendants.map{|p| p.issues.pluck(:id)}.flatten.sort, ids
  49. end
  50. def test_cross_project_scope_with_hierarchy_scope_should_return_hierarchy_issues
  51. project = Project.find(5)
  52. ids = Issue.cross_project_scope(project, 'hierarchy').pluck(:id).sort
  53. assert_equal (project.self_and_descendants + project.ancestors).map{|p| p.issues.pluck(:id)}.flatten.sort, ids
  54. end
  55. def test_cross_project_scope_with_descendants_scope_should_return_descendants_issues
  56. project = Project.find(5)
  57. ids = Issue.cross_project_scope(project, 'descendants').pluck(:id).sort
  58. assert_equal project.self_and_descendants.map{|p| p.issues.pluck(:id)}.flatten.sort, ids
  59. end
  60. end