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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. # Redmine - project management software
  2. # Copyright (C) 2006-2016 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 LayoutTest < Redmine::IntegrationTest
  19. fixtures :projects, :trackers, :issue_statuses, :issues,
  20. :enumerations, :users, :issue_categories,
  21. :projects_trackers,
  22. :roles,
  23. :member_roles,
  24. :members,
  25. :enabled_modules
  26. test "browsing to a missing page should render the base layout" do
  27. get "/users/100000000"
  28. assert_response :not_found
  29. # UsersController uses the admin layout by default
  30. assert_select "#admin-menu", :count => 0
  31. end
  32. test "browsing to an unauthorized page should render the base layout" do
  33. log_user('jsmith','jsmith')
  34. get "/admin"
  35. assert_response :forbidden
  36. assert_select "#admin-menu", :count => 0
  37. end
  38. def test_top_menu_and_search_not_visible_when_login_required
  39. with_settings :login_required => '1' do
  40. get '/'
  41. assert_select "#top-menu > ul", 0
  42. assert_select "#quick-search", 0
  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[src=?]', '/javascripts/jstoolbar/jstoolbar-textile.min.js'
  56. end
  57. def test_calendar_header_tags
  58. with_settings :default_language => 'fr' do
  59. get '/issues'
  60. assert_include "/javascripts/i18n/datepicker-fr.js", response.body
  61. end
  62. with_settings :default_language => 'en-GB' do
  63. get '/issues'
  64. assert_include "/javascripts/i18n/datepicker-en-GB.js", response.body
  65. end
  66. with_settings :default_language => 'en' do
  67. get '/issues'
  68. assert_not_include "/javascripts/i18n/datepicker", response.body
  69. end
  70. with_settings :default_language => 'es' do
  71. get '/issues'
  72. assert_include "/javascripts/i18n/datepicker-es.js", response.body
  73. end
  74. with_settings :default_language => 'es-PA' do
  75. get '/issues'
  76. # There is not datepicker-es-PA.js
  77. # https://github.com/jquery/jquery-ui/tree/1.11.4/ui/i18n
  78. assert_not_include "/javascripts/i18n/datepicker-es.js", response.body
  79. end
  80. with_settings :default_language => 'zh' do
  81. get '/issues'
  82. assert_include "/javascripts/i18n/datepicker-zh-CN.js", response.body
  83. end
  84. with_settings :default_language => 'zh-TW' do
  85. get '/issues'
  86. assert_include "/javascripts/i18n/datepicker-zh-TW.js", response.body
  87. end
  88. with_settings :default_language => 'pt' do
  89. get '/issues'
  90. assert_include "/javascripts/i18n/datepicker-pt.js", response.body
  91. end
  92. with_settings :default_language => 'pt-BR' do
  93. get '/issues'
  94. assert_include "/javascripts/i18n/datepicker-pt-BR.js", response.body
  95. end
  96. end
  97. def test_search_field_outside_project_should_link_to_global_search
  98. get '/'
  99. assert_select 'div#quick-search form[action="/search"]'
  100. end
  101. def test_search_field_inside_project_should_link_to_project_search
  102. get '/projects/ecookbook'
  103. assert_select 'div#quick-search form[action="/projects/ecookbook/search"]'
  104. end
  105. end