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.

help_controller_test.rb 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. # frozen_string_literal: true
  2. # Redmine - project management software
  3. # Copyright (C) 2006- 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 HelpControllerTest < Redmine::ControllerTest
  20. fixtures :users, :email_addresses
  21. def test_get_help_wiki_syntax
  22. formatters = {
  23. :textile => "Wiki Syntax Quick Reference",
  24. :markdown => "Wiki Syntax Quick Reference (Markdown)",
  25. :common_mark => "Wiki Syntax Quick Reference (CommonMark Markdown (GitHub Flavored))"
  26. }
  27. formatters.each do |formatter, result|
  28. with_settings :text_formatting => formatter do
  29. get :show_wiki_syntax
  30. assert_response :success
  31. assert_select 'h1', :text => result
  32. end
  33. end
  34. end
  35. def test_get_help_wiki_syntax_detailed
  36. formatters = {
  37. :textile => "Wiki formatting",
  38. :markdown => "Wiki formatting (Markdown)",
  39. :common_mark => "Wiki formatting (CommonMark Markdown (GitHub Flavored))"
  40. }
  41. formatters.each do |formatter, result|
  42. with_settings :text_formatting => formatter do
  43. get :show_wiki_syntax, :params => {
  44. :type => 'detailed'
  45. }
  46. assert_response :success
  47. assert_select 'h1', :text => result
  48. end
  49. end
  50. end
  51. def test_get_help_wiki_syntax_should_return_lang_if_available
  52. user = User.find(2)
  53. user.language = 'de'
  54. user.save!
  55. @request.session[:user_id] = 2
  56. get :show_wiki_syntax
  57. assert_response :success
  58. assert_select 'h1', :text => "Wiki Syntax Schnellreferenz (CommonMark Markdown (GitHub Flavored))"
  59. end
  60. def test_get_help_wiki_syntax_should_fallback_to_english
  61. user = User.find(2)
  62. user.language = 'ro'
  63. user.save!
  64. @request.session[:user_id] = 2
  65. get :show_wiki_syntax
  66. assert_response :success
  67. assert_select 'h1', :text => "Wiki Syntax Quick Reference (CommonMark Markdown (GitHub Flavored))"
  68. end
  69. def test_get_help_code_highlighting
  70. get :show_code_highlighting
  71. assert_response :success
  72. assert_select 'h1', :text => "List of languages supported by Redmine code highlighter"
  73. # 1-based index + 1 for the header row
  74. index = Rouge::Lexer.all.sort_by(&:tag).index(Rouge::Lexers::Ruby) + 2
  75. assert_select "table tr:nth-of-type(#{index})" do
  76. assert_select '>td:nth-of-type(1)', :text => 'ruby'
  77. assert_select '>td:nth-of-type(2)', :text => /The Ruby programming language/
  78. assert_select '>td:nth-of-type(2)', :text => /\[aliases: rb\]/
  79. end
  80. end
  81. end