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.

layout_test.rb 4.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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 LayoutTest < Redmine::IntegrationTest
  20. fixtures :projects, :trackers, :issue_statuses, :issues,
  21. :enumerations, :users, :issue_categories,
  22. :projects_trackers,
  23. :roles,
  24. :member_roles,
  25. :members,
  26. :enabled_modules
  27. test "browsing to a missing page should render the base layout" do
  28. get "/users/100000000"
  29. assert_response :not_found
  30. # UsersController uses the admin layout by default
  31. assert_select "#admin-menu", :count => 0
  32. end
  33. test "browsing to an unauthorized page should render the base layout" do
  34. log_user('jsmith','jsmith')
  35. get "/admin"
  36. assert_response :forbidden
  37. assert_select "#admin-menu", :count => 0
  38. end
  39. def test_top_menu_and_search_not_visible_when_login_required
  40. with_settings :login_required => '1' do
  41. get '/'
  42. assert_equal response.status, 302
  43. end
  44. end
  45. def test_top_menu_and_search_visible_when_login_not_required
  46. with_settings :login_required => '0' do
  47. get '/'
  48. assert_select "#top-menu > ul"
  49. assert_select "#quick-search"
  50. end
  51. end
  52. def test_wiki_formatter_header_tags
  53. Role.anonymous.add_permission! :add_issues
  54. get '/projects/ecookbook/issues/new'
  55. assert_select "head script:match('src',?)", %r{/assets/jstoolbar/jstoolbar-\w+.js}
  56. assert_include "var userHlLanguages = #{UserPreference::DEFAULT_TOOLBAR_LANGUAGE_OPTIONS.to_json};", response.body
  57. end
  58. def test_calendar_header_tags
  59. with_settings :default_language => 'fr' do
  60. get '/issues'
  61. assert_match %r{/assets/i18n/datepicker-fr-\w+.js}, response.body
  62. end
  63. with_settings :default_language => 'en-GB' do
  64. get '/issues'
  65. assert_match %r{/assets/i18n/datepicker-en-GB-\w+.js}, response.body
  66. end
  67. with_settings :default_language => 'en' do
  68. get '/issues'
  69. assert_not_include "/assets/i18n/datepicker", response.body
  70. end
  71. with_settings :default_language => 'es' do
  72. get '/issues'
  73. assert_match %r{/assets/i18n/datepicker-es-\w+.js}, response.body
  74. end
  75. with_settings :default_language => 'es-PA' do
  76. get '/issues'
  77. # There is not datepicker-es-PA.js
  78. # https://github.com/jquery/jquery-ui/tree/1.11.4/ui/i18n
  79. assert_not_include "/javascripts/i18n/datepicker-es.js", response.body
  80. end
  81. with_settings :default_language => 'zh' do
  82. get '/issues'
  83. assert_match %r{/assets/i18n/datepicker-zh-CN-\w+.js}, response.body
  84. end
  85. with_settings :default_language => 'zh-TW' do
  86. get '/issues'
  87. assert_match %r{/assets/i18n/datepicker-zh-TW-\w+.js}, response.body
  88. end
  89. with_settings :default_language => 'pt' do
  90. get '/issues'
  91. assert_match %r{/assets/i18n/datepicker-pt-\w+.js}, response.body
  92. end
  93. with_settings :default_language => 'pt-BR' do
  94. get '/issues'
  95. assert_match %r{/assets/i18n/datepicker-pt-BR-\w+.js}, response.body
  96. end
  97. end
  98. def test_search_field_outside_project_should_link_to_global_search
  99. get '/'
  100. assert_select 'div#quick-search form[action="/search"]'
  101. end
  102. def test_search_field_inside_project_should_link_to_project_search
  103. get '/projects/ecookbook'
  104. assert_select 'div#quick-search form[action="/projects/ecookbook/search"]'
  105. end
  106. def test_help_and_powered_by_redmine_link_should_open_separate_tab
  107. get '/'
  108. assert_select '#top-menu a.help[target="_blank"][rel="noopener"]'
  109. # "Powered by Redmine" link
  110. assert_select '#footer a[target="_blank"][rel="noopener"]'
  111. end
  112. end