Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

application_test.rb 3.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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 ApplicationTest < Redmine::IntegrationTest
  19. include Redmine::I18n
  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. def test_set_localization
  28. Setting.default_language = 'en'
  29. # a french user
  30. get '/projects', { }, 'HTTP_ACCEPT_LANGUAGE' => 'fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3'
  31. assert_response :success
  32. assert_select 'h2', :text => 'Projets'
  33. assert_equal :fr, current_language
  34. assert_select "html[lang=?]", "fr"
  35. # then an italien user
  36. get '/projects', { }, 'HTTP_ACCEPT_LANGUAGE' => 'it;q=0.8,en-us;q=0.5,en;q=0.3'
  37. assert_response :success
  38. assert_select 'h2', :text => 'Progetti'
  39. assert_equal :it, current_language
  40. assert_select "html[lang=?]", "it"
  41. # not a supported language: default language should be used
  42. get '/projects', { }, 'HTTP_ACCEPT_LANGUAGE' => 'zz'
  43. assert_response :success
  44. assert_select 'h2', :text => 'Projects'
  45. assert_select "html[lang=?]", "en"
  46. end
  47. def test_token_based_access_should_not_start_session
  48. # issue of a private project
  49. get '/issues/4.atom'
  50. assert_response 302
  51. rss_key = User.find(2).rss_key
  52. get "/issues/4.atom?key=#{rss_key}"
  53. assert_response 200
  54. assert_nil session[:user_id]
  55. end
  56. def test_missing_template_should_respond_with_404
  57. get '/login.png'
  58. assert_response 404
  59. end
  60. def test_invalid_token_should_call_custom_handler
  61. ActionController::Base.allow_forgery_protection = true
  62. post '/issues'
  63. assert_response 422
  64. assert_include "Invalid form authenticity token.", response.body
  65. ensure
  66. ActionController::Base.allow_forgery_protection = false
  67. end
  68. def test_localization_should_be_set_correctly_on_invalid_token
  69. ActionController::Base.allow_forgery_protection = true
  70. Setting.default_language = 'en'
  71. post '/issues', { }, 'HTTP_ACCEPT_LANGUAGE' => 'fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3'
  72. assert_response 422
  73. assert_equal :fr, current_language
  74. assert_select "html[lang=?]", "fr"
  75. ensure
  76. ActionController::Base.allow_forgery_protection = false
  77. end
  78. def test_require_login_with_pdf_format_should_not_error
  79. with_settings :login_required => '1' do
  80. get '/issues/1.pdf'
  81. assert_response 302
  82. end
  83. end
  84. end