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.

projects_helper_test.rb 2.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. # frozen_string_literal: true
  2. # Redmine - project management software
  3. # Copyright (C) 2006-2023 Jean-Philippe Lang
  4. #
  5. # This program is free software; you can redistribute it and/or
  6. # modify it under the terms of the GNU General Public License
  7. # as published by the Free Software Foundation; either version 2
  8. # of the License, or (at your option) any later version.
  9. #
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # GNU General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License
  16. # along with this program; if not, write to the Free Software
  17. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  18. require_relative '../test_helper'
  19. class ProjectsHelperTest < Redmine::HelperTest
  20. include ApplicationHelper
  21. include ProjectsHelper
  22. include ERB::Util
  23. include Rails.application.routes.url_helpers
  24. fixtures :projects, :trackers, :issue_statuses, :issues,
  25. :enumerations, :users, :issue_categories,
  26. :versions,
  27. :projects_trackers,
  28. :member_roles,
  29. :members,
  30. :groups_users,
  31. :enabled_modules
  32. def test_link_to_version_within_project
  33. @project = Project.find(2)
  34. User.current = User.find(1)
  35. assert_equal '<a title="07/01/2006" href="/versions/5">Alpha</a>', link_to_version(Version.find(5))
  36. end
  37. def test_link_to_version
  38. User.current = User.find(1)
  39. assert_equal '<a title="07/01/2006" href="/versions/5">OnlineStore - Alpha</a>', link_to_version(Version.find(5))
  40. end
  41. def test_link_to_version_without_effective_date
  42. User.current = User.find(1)
  43. version = Version.find(5)
  44. version.effective_date = nil
  45. assert_equal '<a href="/versions/5">OnlineStore - Alpha</a>', link_to_version(version)
  46. end
  47. def test_link_to_private_version
  48. assert_equal 'OnlineStore - Alpha', link_to_version(Version.find(5))
  49. end
  50. def test_link_to_version_invalid_version
  51. assert_equal '', link_to_version(Object)
  52. end
  53. def test_format_version_name_within_project
  54. @project = Project.find(1)
  55. assert_equal "0.1", format_version_name(Version.find(1))
  56. end
  57. def test_format_version_name
  58. assert_equal "eCookbook - 0.1", format_version_name(Version.find(1))
  59. end
  60. def test_format_version_name_for_system_version
  61. assert_equal "OnlineStore - Systemwide visible version", format_version_name(Version.find(7))
  62. end
  63. def test_version_options_for_select_with_no_versions
  64. assert_equal '', version_options_for_select([])
  65. assert_equal '', version_options_for_select([], Version.find(1))
  66. end
  67. end