Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

previews_controller_test.rb 3.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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 PreviewsControllerTest < Redmine::ControllerTest
  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. :journals, :journal_details,
  28. :news
  29. def test_preview_new_issue_description
  30. @request.session[:user_id] = 2
  31. post(
  32. :issue,
  33. :params => {
  34. :project_id => '1',
  35. :text => 'Foo'
  36. }
  37. )
  38. assert_response :success
  39. assert_select 'p', :text => 'Foo'
  40. end
  41. def test_preview_issue_description
  42. @request.session[:user_id] = 2
  43. post(
  44. :issue,
  45. :params => {
  46. :project_id => '1',
  47. :issue_id => 1,
  48. :text => 'Unable to print recipes'
  49. }
  50. )
  51. assert_response :success
  52. assert_select 'p', :text => 'Unable to print recipes'
  53. end
  54. def test_preview_issue_notes
  55. @request.session[:user_id] = 2
  56. post(
  57. :issue,
  58. :params => {
  59. :project_id => '1',
  60. :id => 1,
  61. :text => 'Foo'
  62. }
  63. )
  64. assert_response :success
  65. assert_select 'p', :text => 'Foo'
  66. end
  67. def test_preview_issue_notes_should_support_links_to_existing_attachments
  68. Attachment.generate!(:container => Issue.find(1), :filename => 'foo.bar')
  69. @request.session[:user_id] = 2
  70. post(
  71. :issue,
  72. :params => {
  73. :project_id => '1',
  74. :issue_id => 1,
  75. :field => 'notes',
  76. :text => 'attachment:foo.bar'
  77. }
  78. )
  79. assert_response :success
  80. assert_select 'a.attachment', :text => 'foo.bar'
  81. end
  82. def test_preview_issue_notes_should_show_thumbnail_of_file_immidiately_after_attachment
  83. attachment = Attachment.generate!(filename: 'foo.png', digest: Redmine::Utils.random_hex(32))
  84. attachment.update(container: nil)
  85. @request.session[:user_id] = 2
  86. post(
  87. :issue,
  88. params: {
  89. project_id: '1',
  90. issue_id: 1,
  91. field: 'notes',
  92. text: '{{thumbnail(foo.png)}}',
  93. attachments: {'1': { token: attachment.token }}
  94. }
  95. )
  96. assert_response :success
  97. assert_select 'a.thumbnail[title=?]', 'foo.png'
  98. end
  99. def test_preview_new_news
  100. get(
  101. :news,
  102. :params => {
  103. :project_id => 1,
  104. :text => 'News description',
  105. }
  106. )
  107. assert_response :success
  108. assert_select 'p', :text => /News description/
  109. end
  110. def test_preview_existing_news
  111. get(
  112. :news,
  113. :params => {
  114. :project_id => 1,
  115. :id => 2,
  116. :text => 'News description'
  117. }
  118. )
  119. assert_response :success
  120. assert_select 'p', :text => /News description/
  121. end
  122. end