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.

wiki_test.rb 2.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. # frozen_string_literal: true
  2. # Redmine - project management software
  3. # Copyright (C) 2006-2021 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 WikiIntegrationTest < Redmine::IntegrationTest
  20. fixtures :projects,
  21. :users, :email_addresses,
  22. :roles,
  23. :members,
  24. :member_roles,
  25. :trackers,
  26. :projects_trackers,
  27. :enabled_modules,
  28. :wikis,
  29. :wiki_pages,
  30. :wiki_contents
  31. def test_updating_a_renamed_page
  32. log_user('jsmith', 'jsmith')
  33. get '/projects/ecookbook/wiki'
  34. assert_response :success
  35. get '/projects/ecookbook/wiki/Wiki/edit'
  36. assert_response :success
  37. # this update should not end up with a loss of content
  38. put(
  39. '/projects/ecookbook/wiki/Wiki',
  40. :params => {
  41. :content => {
  42. :text => "# Wiki\r\n\r\ncontent",
  43. :comments => ""
  44. },
  45. :wiki_page => {:parent_id => ""}
  46. }
  47. )
  48. assert_redirected_to "/projects/ecookbook/wiki/Wiki"
  49. follow_redirect!
  50. assert_select 'div', /content/
  51. assert content = WikiContent.last
  52. # Let's assume somebody else, or the same user in another tab, renames the
  53. # page while it is being edited.
  54. post(
  55. '/projects/ecookbook/wiki/Wiki/rename',
  56. :params => {
  57. :wiki_page => {:title => "NewTitle"}
  58. }
  59. )
  60. assert_redirected_to "/projects/ecookbook/wiki/NewTitle"
  61. # this update should not end up with a loss of content
  62. put(
  63. '/projects/ecookbook/wiki/Wiki',
  64. :params => {
  65. :content => {
  66. :version => content.version,
  67. :text => "# Wiki\r\n\r\nnew content",
  68. :comments => ""
  69. },
  70. :wiki_page => {:parent_id => ""}
  71. }
  72. )
  73. assert_redirected_to "/projects/ecookbook/wiki/NewTitle"
  74. follow_redirect!
  75. assert_select 'div', /new content/
  76. end
  77. end