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.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. # frozen_string_literal: true
  2. # Redmine - project management software
  3. # Copyright (C) 2006-2019 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 File.expand_path('../../test_helper', __FILE__)
  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_select "#top-menu > ul", 0
  43. assert_select "#quick-search", 0
  44. end
  45. end
  46. def test_top_menu_and_search_visible_when_login_not_required
  47. with_settings :login_required => '0' do
  48. get '/'
  49. assert_select "#top-menu > ul"
  50. assert_select "#quick-search"
  51. end
  52. end
  53. def test_wiki_formatter_header_tags
  54. Role.anonymous.add_permission! :add_issues
  55. get '/projects/ecookbook/issues/new'
  56. assert_select 'head script[src^=?]', '/javascripts/jstoolbar/jstoolbar.js?'
  57. assert_include "var userHlLanguages = #{UserPreference::DEFAULT_TOOLBAR_LANGUAGE_OPTIONS.to_json};", response.body
  58. end
  59. def test_calendar_header_tags
  60. with_settings :default_language => 'fr' do
  61. get '/issues'
  62. assert_include "/javascripts/i18n/datepicker-fr.js", response.body
  63. end
  64. with_settings :default_language => 'en-GB' do
  65. get '/issues'
  66. assert_include "/javascripts/i18n/datepicker-en-GB.js", response.body
  67. end
  68. with_settings :default_language => 'en' do
  69. get '/issues'
  70. assert_not_include "/javascripts/i18n/datepicker", response.body
  71. end
  72. with_settings :default_language => 'es' do
  73. get '/issues'
  74. assert_include "/javascripts/i18n/datepicker-es.js", response.body
  75. end
  76. with_settings :default_language => 'es-PA' do
  77. get '/issues'
  78. # There is not datepicker-es-PA.js
  79. # https://github.com/jquery/jquery-ui/tree/1.11.4/ui/i18n
  80. assert_not_include "/javascripts/i18n/datepicker-es.js", response.body
  81. end
  82. with_settings :default_language => 'zh' do
  83. get '/issues'
  84. assert_include "/javascripts/i18n/datepicker-zh-CN.js", response.body
  85. end
  86. with_settings :default_language => 'zh-TW' do
  87. get '/issues'
  88. assert_include "/javascripts/i18n/datepicker-zh-TW.js", response.body
  89. end
  90. with_settings :default_language => 'pt' do
  91. get '/issues'
  92. assert_include "/javascripts/i18n/datepicker-pt.js", response.body
  93. end
  94. with_settings :default_language => 'pt-BR' do
  95. get '/issues'
  96. assert_include "/javascripts/i18n/datepicker-pt-BR.js", response.body
  97. end
  98. end
  99. def test_search_field_outside_project_should_link_to_global_search
  100. get '/'
  101. assert_select 'div#quick-search form[action="/search"]'
  102. end
  103. def test_search_field_inside_project_should_link_to_project_search
  104. get '/projects/ecookbook'
  105. assert_select 'div#quick-search form[action="/projects/ecookbook/search"]'
  106. end
  107. end